LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Zero single partitions (not whole drives)? (http://www.linuxquestions.org/questions/slackware-14/zero-single-partitions-not-whole-drives-4175422162/)

kikinovak 08-15-2012 05:13 AM

Zero single partitions (not whole drives)?
 
Hi,

One of my PCs is a dedicated Slackware build box. Currently I have two systems installed on it: Slackware 13.37 and Slackware64 13.37. The main purpose of this machine is to build packages (mine or from SBo), so I can easily install them on many machines from here.

The current partitioning scheme looks like this:

Code:

[root@betadine:~] # fdisk -l /dev/sda

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 têtes, 63 secteurs/piste, 9729 cylindres, total 156301488 secteurs
Unités = secteurs de 1 * 512 = 512 octets
Taille de secteur (logique / physique)*: 512*octets / 512*octets
taille d'E/S (minimale / optimale)*: 512*octets / 512*octets
Identifiant de disque*: 0x0005ac98

Périphérique Amorce  Début        Fin      Blocs    Id  Système
/dev/sda1              63    4000184    2000061  82  Linux swap
/dev/sda2  *    4000185    4192964      96390  83  Linux
/dev/sda3        4192965    42090299    18948667+  83  Linux
/dev/sda4        42090300  156301487    57105594    5  Étendue
/dev/sda5  *    42090363    42283079      96358+  83  Linux
/dev/sda6        42283143    80180414    18948636  83  Linux
/dev/sda7  *    80180478    80373194      96358+  83  Linux
/dev/sda8        80373258  118270529    18948636  83  Linux
/dev/sda9  *  118270593  118463309      96358+  83  Linux
/dev/sda10      118463373  156301487    18919057+  83  Linux

- sda1 is the swap partition shared by all the installed systems
- Slackware 13.37 is installed on sda2 and sda3
- Slackware64 13.37 is installed on sda5 and sda6.

Currently, partitions sda7 to sda10 are unused. They're supposed to get two fresh installs of Slackware 14.0 and Slackware64 14.0 as soon as the stable release is out.

In the meantime, whenever I have to do some experimenting that's liable to create havoc, I always backup the machine using G4L (Ghost For Linux). This simple software sends the raw contents of the hard disk to a local FTP server, byte by byte.

Usually I try to reduce the size of the compressed disk images by writing zeros to every unused area of the disk before backing it up, somehow like this. Within the installed system:

Code:

# dd if=/dev/zero of=/0bits bs=20M ; rm -f /0bits
Now I wonder if I can simply write zeros to single partitions from, say, a live system. Say I'd like to fill only sda7 with zeros, can I issue the following command?

Code:

# dd if=/dev/zero of=/dev/sda7
Of course, this shouldn't affect all the other partitions (sda1-6, sda8-10).

I'm not exactly sure, so I'd better ask first, since an error of judgement could destroy a few days' work.

syg00 08-15-2012 05:21 AM

Yes. A better solution is to simply mkfs.

TobiSGD 08-15-2012 06:27 AM

Quote:

Originally Posted by syg00 (Post 4754515)
Yes. A better solution is to simply mkfs.

Actually it is not a better solution to use mkfs. mkfs will not zero out the partition, so you will not get a better compression rate.

@kikinovak: Your approach with dd will work fine. I would recommend to play a bit with the blocksizes (default is 512 bytes) to get better performance, I get the best performance in the range between 8 and 32MB (seems to be dependent on the hardware).

syg00 08-15-2012 06:31 AM

I stand corrected - I glossed over the compression requirement.

kikinovak 08-15-2012 08:42 AM

Quote:

Originally Posted by TobiSGD (Post 4754545)
@kikinovak: Your approach with dd will work fine. I would recommend to play a bit with the blocksizes (default is 512 bytes) to get better performance, I get the best performance in the range between 8 and 32MB (seems to be dependent on the hardware).

OK, thanks. That worked. When I invoke dd from within the system, I usually choose bs=20M for best performance.


All times are GMT -5. The time now is 01:49 PM.