Archive for the ‘Filesystem’ Category

* 1 hard disk completely installed as I like it.
* 1 hard disk without format.
* 1 extern disk with just format.
* VERY IMPORTANT: All hard disks must be to same size.

To copy the hard disk, which is completely installed as I like it, to an extern empty disk, first boot with a rescue cd then run:

root@buzz:~# dd if=/dev/sda of=/dev/sdb bs=2G 2> dd.errors

Notice that dd.errors is a file where all errors will be redirected.
if means “input file”, in that case is the hard disk that is completely installed as I like it.
of means “output file”, in that case is the extern disk.
bs means count of blocks at a time. In that case are blocks of 2G. It shouldn’t be more than the size ram.

Now, you should ran dd one more time, from extern disk to the disk without format. So boot with a recue cd again in order to access to disk without format.

root@buzz:~# dd if=/dev/sdb of=/dev/sda bs=2G 2> dd.errors

Reboot it, without rescue cd! aaaand enjoy!!

I will assume that the device will be format is called /dev/sdb

1. You should assure the device is unmounted.

# umount /dev/sdb

2. Fdisk is an Unix tool usefull to format devices.

# fdisk -l /dev/sdb

Usefull parameters:

2.1 -l list partitions table.
2.2 d delete partitions.
2.3 n Create partitions.
2.4 t Change partition type.
2.5 w Write changes.
2.6 q Quit.

3. Disconnect usb stick and come back to connect.

4. Format the usb stick.

# mkfs -t vfat /dev/sdb1

LVM is a logical volume manager for Linux kernel. It’s based on Veritas’s logical volume manager.
LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting existing ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncating extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to RAID 0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID 1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split). This can be useful when migrating whole logical volumes to or from offline storage.
  • (Last pharagraph was taken from Wikipedia)

    1. You can create a Physical Volume on whole disk or on a patition.

    # pvcreate /dev/sda

    2. Create a Volume Group too.

    # vgcreate vg0 /dev/sda

    3. Create a Logical Volume inside Volume Group created recently.

    # lvcreate -n lv_home --size 40g vg0

    4. Format the lv_home partition.

    # mkfs.ext3 -L home /dev/mapper/lv_home

    5. You have to add entries in ”/etc/fstab” file.

    # vi /etc/fstab

    /dev/mapper/home /home ext3 defaults,noatime 0 2 0

    5. Add necessaries data to ramdisk

    # update-initramfs -u -k all

    6. Extend a LVM partition
    6.1 Boot the system using a live cd
    6.2 Umount the partition to be extended.


    6.3 Extend the Logical partition to 2G (giga)

    #lvextend --size +2G -n /dev/localvg/usrlv

    6.4 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    6.5 Extend the filesystem

    #resize2fs /dev/localvg/usrlv

    6.6 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    7. Reduce a LVM partition
    7.1 Umount the partition

    #umount /home

    7.2 Reduce the filesystem

    #resize2fs /dev/myvg/homevol 524288

    7.3 Reduce the LVM partition

    #lvreduce -L-1G /dev/myvg/homevol

    7.4 Run fsck

    #e2fsck -f /dev/myvg/homevol

    7.5 Mount the partition

    # mount /home

    • analialorenzatto: Buzz is just a host name for this example, it doesn't have any relation to the topic. Instead of being "Buzz", could be whatever name.
    • fridelain: >buzz What's the story behind this host name? Actully running buzz, once running buzz and upgraded many times since, or unrelated to debian naming
    • Pratik: Nice, but I would change it to include more directories. Like my .mozilla and .kde4 by using .{config,mozilla,kde4} instead of just .config .