|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Can anyone please recommend the best way to programatically obtain disk
drive information, partition, and format from an install script? I presume I could parse the output of "fdisk -l" to get the drive info. Seems like there has got to be a better or less error prone method for doing this sort of stuff. Also, fdisk is interactive. I'd like to emulate something like the Debian installer that lists the various drives and partitions, allows the user to setup partitions and format, as well as select the partition to install Linux to. Any recommendations will be greatly appreciated! Regards, Dallas Clement -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Not the best way, but it works perfectly
See attached Shell-Script. Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGeTm6C0FPBMSS+BIRAra9AKCdHuNmyt+PdgVEyxzota MfeuilqgCfXgPU HYUYzsqcuO1gV/NKpgX8fMc= =io2Q -----END PGP SIGNATURE----- |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Am 2007-06-14 19:00:47, schrieb Orestes leal:
> $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ print $0 }' | grep '/dev/sd' > particiones.txt Can you tell me which version of "fdisk" you are using? "fdisk -l" returns nothing at all (¶USER or root) > detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $2 }') > detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $1 }') > $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ print $0 }' | grep '/dev/hd' > particiones.txt > detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $2 }') > detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $1 }') And why do you run fdisk so many times? You can use ONCE: FDISKOUT=$(fdisk -l) and then echo -e "${FDISKOUT}" | some_command ... ^^ Do not forget it. :-) Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGeTm3C0FPBMSS+BIRAlp+AKCfbjZElsP4Kil5OI2e/QI9KMvYmQCdGhTe OHQGP6oea7mFmGMUCPiG6Aw= =JW4l -----END PGP SIGNATURE----- |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Wed, 20 Jun 2007 16:29:12 +0200
Michelle Konzack <linux4michelle@freenet.de> wrote: > Am 2007-06-14 19:00:47, schrieb Orestes leal: > > $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ print $0 }' | grep '/dev/sd' > particiones.txt > > Can you tell me which version of "fdisk" you are using? > "fdisk -l" returns nothing at all (¶USER or root) fdisk v2.12r > > > detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $2 }') > > detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $1 }') > > $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ print $0 }' | grep '/dev/hd' > particiones.txt > > detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $2 }') > > detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print $2}' | gawk -F' ' '{ print $1 }') > > And why do you run fdisk so many times? I'am not a shell master at all, i'am a newbie. > > You can use ONCE: > > FDISKOUT=$(fdisk -l) > > and then > > echo -e "${FDISKOUT}" | some_command ... > ^^ > Do not forget it. :-) Thanks. > > Thanks, Greetings and nice Day Ore. Orestes <orestesleal13022@cha.jovenclub.cu> |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Michelle Konzack wrote:
> Not the best way, but it works perfectly > > See attached Shell-Script. > This is what I have: hugo@debian:~$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 7692876 2444696 4857404 34% / tmpfs 518188 0 518188 0% /lib/init/rw udev 10240 160 10080 2% /dev tmpfs 518188 0 518188 0% /dev/shm /dev/hda5 5862271 2360287 3204122 43% /hda5 /dev/hda6 5862271 2658527 2905882 48% /hda6 /dev/hda7 26647936 4765152 20529144 19% /hda7 /dev/hda10 29362324 8058008 19812756 29% /hda10 /dev/hdc1 7692876 3131516 4561360 41% /hdb1 /dev/hdc2 7692908 2721760 4580368 38% /hdb2 /dev/hdc3 7691004 3704415 3595808 51% /hdb3 /dev/hdc5 7690972 3509439 3790754 49% /hdb5 /dev/hdc6 7692156 3016492 4363044 41% /hdb6 /dev/hdc7 38456308 18747544 17755264 52% /hdb7 /dev/sda2 7692908 4042996 3259132 56% /sda2 /dev/sda3 7691004 3563058 3737165 49% /sda3 /dev/sda5 7690972 4135476 3164717 57% /sda5 /dev/sda6 7690972 4887187 2413006 67% /sda6 /dev/sda7 38456308 10881196 25621612 30% /sda7 hugo@debian:~$ I run ./get_partitions.sh and it shows nothing. Is it supposed to? Thanks Michelle, Hugo -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Wed, 20 Jun 2007 12:53:19 -0500
Hugo Vanwoerkom <hvw59601@care2.com> wrote: > Michelle Konzack wrote: > > Not the best way, but it works perfectly > > > > See attached Shell-Script. > > > > This is what I have: > > hugo@debian:~$ df > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda1 7692876 2444696 4857404 34% / > tmpfs 518188 0 518188 0% /lib/init/rw > udev 10240 160 10080 2% /dev > tmpfs 518188 0 518188 0% /dev/shm > /dev/hda5 5862271 2360287 3204122 43% /hda5 > /dev/hda6 5862271 2658527 2905882 48% /hda6 > /dev/hda7 26647936 4765152 20529144 19% /hda7 > /dev/hda10 29362324 8058008 19812756 29% /hda10 > /dev/hdc1 7692876 3131516 4561360 41% /hdb1 > /dev/hdc2 7692908 2721760 4580368 38% /hdb2 > /dev/hdc3 7691004 3704415 3595808 51% /hdb3 > /dev/hdc5 7690972 3509439 3790754 49% /hdb5 > /dev/hdc6 7692156 3016492 4363044 41% /hdb6 > /dev/hdc7 38456308 18747544 17755264 52% /hdb7 > /dev/sda2 7692908 4042996 3259132 56% /sda2 > /dev/sda3 7691004 3563058 3737165 49% /sda3 > /dev/sda5 7690972 4135476 3164717 57% /sda5 > /dev/sda6 7690972 4887187 2413006 67% /sda6 > /dev/sda7 38456308 10881196 25621612 30% /sda7 > hugo@debian:~$ > > I run ./get_partitions.sh and it shows nothing. > Is it supposed to? happen the same to me. ? > Thanks Michelle, > > Hugo > > > -- > To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org -- Orestes <orestesleal13022@cha.jovenclub.cu> -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Orestes leal wrote:
> On Wed, 20 Jun 2007 12:53:19 -0500 > Hugo Vanwoerkom <hvw59601@care2.com> wrote: > >> Michelle Konzack wrote: >>> Not the best way, but it works perfectly >>> >>> See attached Shell-Script. >>> >> This is what I have: >> >> hugo@debian:~$ df >> Filesystem 1K-blocks Used Available Use% Mounted on >> /dev/sda1 7692876 2444696 4857404 34% / >> tmpfs 518188 0 518188 0% /lib/init/rw >> udev 10240 160 10080 2% /dev >> tmpfs 518188 0 518188 0% /dev/shm >> /dev/hda5 5862271 2360287 3204122 43% /hda5 >> /dev/hda6 5862271 2658527 2905882 48% /hda6 >> /dev/hda7 26647936 4765152 20529144 19% /hda7 >> /dev/hda10 29362324 8058008 19812756 29% /hda10 >> /dev/hdc1 7692876 3131516 4561360 41% /hdb1 >> /dev/hdc2 7692908 2721760 4580368 38% /hdb2 >> /dev/hdc3 7691004 3704415 3595808 51% /hdb3 >> /dev/hdc5 7690972 3509439 3790754 49% /hdb5 >> /dev/hdc6 7692156 3016492 4363044 41% /hdb6 >> /dev/hdc7 38456308 18747544 17755264 52% /hdb7 >> /dev/sda2 7692908 4042996 3259132 56% /sda2 >> /dev/sda3 7691004 3563058 3737165 49% /sda3 >> /dev/sda5 7690972 4135476 3164717 57% /sda5 >> /dev/sda6 7690972 4887187 2413006 67% /sda6 >> /dev/sda7 38456308 10881196 25621612 30% /sda7 >> hugo@debian:~$ >> >> I run ./get_partitions.sh and it shows nothing. >> Is it supposed to? > > happen the same to me. ? > The secret is that fdisk is in /sbin and a normal user cannot see that so the script does nothing. You have to be root to use the script. Or use sudoers to make fdisk visible to normal users. If I su myself I get: /home/hugoThu Jun 21-08:29:43SDA1# ./get_partitions.sh Found partition(s) on disk /dev/hda /dev/hda1 6054520 c W95 FAT32 (LBA) /dev/hda2 73988681 f W95 Ext'd (LBA) /dev/hda5 5957248 83 Linux /dev/hda6 5957248 83 Linux /dev/hda7 27072832 83 Linux /dev/hda8 4193248 c W95 FAT32 (LBA) /dev/hda9 976720 82 Linux swap / Solaris /dev/hda10 29831224 83 Linux Found partition(s) on disk /dev/hdc /dev/hdc1 7815591 83 Linux /dev/hdc2 7815622 83 Linux /dev/hdc3 7815622 83 Linux /dev/hdc4 54701325 5 Extended /dev/hdc5 7815591 83 Linux /dev/hdc6 7815591 83 Linux /dev/hdc7 39070048 83 Linux Found partition(s) on disk /dev/sda /dev/sda1 7815591 83 Linux /dev/sda2 7815622 83 Linux /dev/sda3 7815622 83 Linux /dev/sda4 54701325 5 Extended /dev/sda5 7815591 83 Linux /dev/sda6 7815591 83 Linux /dev/sda7 39070048 83 Linux /home/hugoThu Jun 21-08:30:34SDA1# Works nicer than cfdisk because you can see everything at once. Calls for a dialog implementation so that it "looks nice". Thanks Michelle, again, but I think he isn't watching right now. Hugo -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Am 2007-06-20 11:54:02, schrieb Orestes leal:
> On Wed, 20 Jun 2007 16:29:12 +0200 > Michelle Konzack <linux4michelle@freenet.de> wrote: > > Can you tell me which version of "fdisk" you are using? > > "fdisk -l" returns nothing at all (¶USER or root) > > fdisk v2.12r :-/ I have v2.12p Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGhRdcC0FPBMSS+BIRAvrEAJ9gWoQkrHRxWqps5Siiyq 8jU0VWTQCgz2Hj OOG/5sXVq+bl3N0JU7DOLpc= =YWCi -----END PGP SIGNATURE----- |
|
![]() |
| Outils de la discussion | |
|
|