sys03 - filesystem & disk layout

# at start:
df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md2             1065281580    726100 1010868448   1% /
tmpfs                  8080436         0   8080436   0% /lib/init/rw
udev                   8074924       164   8074760   1% /dev
tmpfs                  8080436         0   8080436   0% /dev/shm
/dev/md1                507836     37996    443628   8% /boot
/dev/md3             1828890816    200560 1736519540   1% /home

(parted) p
Model: ATA ST3000DM001-9YN1 (scsi)
Disk /dev/sda: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  13.4GB  537MB                      raid
 3      13.4GB  1113GB  1100GB                     raid
 4      1113GB  3001GB  1888GB                     raid

this does not fit the operational concept (vserver host
with individual volumes per vserver)

##
## plan:
##    lvm setup
##    repartitioning (1TB slices to reduce possible crash impacts )
##    create lvs for / and /boot
##
##
## disk-reorg:
##   there are 12GB swap which are not really is use now
##   we move the base system there so we can work on the rest of the disk
##
apt-get install lvm2
swapoff -a
pvcreate /dev/md0
vgcreate vgsys03 /dev/md0
lvcreate vgsys03 -n lv01root -L +2GB
lvcreate vgsys03 -n lv02boot -L +1GB
mkfs -t ext4 /dev/vgsys03/lv01root
mkfs -t ext4 /dev/vgsys03/lv02boot
mkdir /mnt/root
mount /dev/vgsys03/lv01root /mnt/root
mkdir /mnt/boot
mount /dev/vgsys03/lv02boot /mnt/boot
rsync -v -l -H -p -o -g -D -t -r -S -e ssh --delete --numeric-ids --stats . /mnt/root --exclude "/dev/*" --exclude "/boot/*" --exclude "/home/*" --exclude "/proc/*" --exclude "/sys/*" --exclude "/mnt/*"
rsync -v -l -H -p -o -g -D -t -r -S -e ssh --delete --numeric-ids --stats "/boot/" /mnt/root/boot/
umount /mnt/boot
mount /dev/vgsys03/lv02boot /mnt/root/boot
mount -o bind /dev /mnt/root/dev
mount -t proc /proc /mnt/root/proc
chroot /mnt/root
grub-install /dev/sda
grub-install /dev/sdb
update-grub
less /boot/grub/grub.cfg
vi /mnt/root/etc/fstab
  proc /proc proc defaults 0 0
  none /dev/pts devpts gid=5,mode=620 0 0
  /dev/md/0 none swap sw 0 0
  /dev/md/1 /boot ext3 defaults 0 0
  /dev/md/2 / ext4 defaults 0 0
  /dev/md/3 /home ext4 defaults 0 0
->
  proc /proc proc defaults 0 0
  none /dev/pts devpts gid=5,mode=620 0 0
  #/dev/md/0 none swap sw 0 0
  /dev/vgsys03/lv02boot /boot ext4 defaults 0 0
  /dev/vgsys03/lv01root / ext4 defaults 0 0
  #/dev/md/3 /home ext4 defaults 0 0
exit  # chroot
reboot

## /usr and /var are copie to their own volumes
lvcreate vgsys03 -n lv02var -L +2G
lvcreate vgsys03 -n lv03usr -L +2G
lvcreate vgsys03 -n lv04home -L +2G
mkfs -t ext4 /dev/vgsys03/lv02var
mkfs -t ext4 /dev/vgsys03/lv03usr
mkfs -t ext4 /dev/vgsys03/lv04home
vi /etc/fstab
    /dev/vgsys03/lv04home /home ext4 defaults 0 0
mount /home
mount /dev/vgsys03/lv02var /mnt
rsync -v -l -H -p -o -g -D -t -r -S --delete --numeric-ids --stats "/var/" "/mnt/"
umount /mnt
vi /etc/fstab
    /dev/vgsys03/lv02var /var ext4 defaults 0 0
mount /var

mount /dev/vgsys03/lv03usr /mnt
rsync -v -l -H -p -o -g -D -t -r -S --delete --numeric-ids --stats "/usr/" "/mnt/"
umount /mnt
vi /etc/fstab
    /dev/vgsys03/lv03usr /usr ext4 defaults 0 0
mount /usr

# trick: the file system contents existing so far in /usr and /var on the root fs are now spurious
# using a 2nd mount on the root fs makes them accessible for deletion
# dort geloescht werden
mount /dev/mapper/vgsys03-lv01root /mnt
rm -rf /mnt/var/* /mnt/usr/*
umount /mnt

##
## repartitioning
##
mdadm --stop /dev/md3
mdadm --stop /dev/md2
mdadm --stop /dev/md1

## sda
parted /dev/sda
rm 4
rm 3
rm 2
Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  13.4GB  537MB                      raid
 3      13.4GB  1113GB  1100GB                     raid
 4      1113GB  3001GB  1888GB                     raid

mkpart " " 12.9GB 1TB
mkpart " " 1TB 2TB
mkpart " " 2TB 3TB
toggle 2 raid
toggle 3 raid
toggle 4 raid
p
Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  1000GB  987GB                      raid
 3      1000GB  2000GB  1000GB                     raid
 4      2000GB  3001GB  1001GB                     raid
q

## sdb
parted /dev/sdb
rm 4
rm 3
rm 2
mkpart " " 12.9GB 1TB
mkpart " " 1TB 2TB
mkpart " " 2TB 3TB
toggle 2 raid
toggle 3 raid
toggle 4 raid
p
Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  1000GB  987GB                      raid
 3      1000GB  2000GB  1000GB                     raid
 4      2000GB  3001GB  1001GB                     raid

## raid re-assemble
mdadm --create /dev/md1 -l 1 -n 2 --add /dev/sda2 --add /dev/sdb2
mdadm --create /dev/md2 -l 1 -n 2 --add /dev/sda3 --add /dev/sdb3
mdadm --create /dev/md3 -l 1 -n 2 --add /dev/sda4 --add /dev/sdb4
mdadm --assemble /dev/md1
mdadm --assemble /dev/md2
mdadm --assemble /dev/md3
mdadm --run /dev/md1
mdadm --run /dev/md2
mdadm --run /dev/md3

## vg resize
##
pvcreate /dev/md1
pvcreate /dev/md2
pvcreate /dev/md3
# just md1, the vg does not need to be any larger for now
vgextend vgsys03 /dev/md1

## recreate swap
##
lvcreate vgsys03 -n lv05swap -L +16G
mkswap -L SWAP01 /dev/vgsys03/lv05swap
vi /etc/fstab
        /dev/vgsys03/lv05swap none swap sw 0 0
swapon -a

# finally
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vgsys03-lv01root
                       2064208    199392   1759960  11% /
tmpfs                  8080436         0   8080436   0% /lib/init/rw
udev                   8074924       184   8074740   1% /dev
tmpfs                  8080436         0   8080436   0% /dev/shm
/dev/vgsys03/lv02boot  1032088     55200    924460   6% /boot
/dev/vgsys03/lv04home  2064208     68608   1890744   4% /home
/dev/vgsys03/lv02var   2064208    219072   1740280  12% /var
/dev/vgsys03/lv03usr   2064208    318912   1640440  17% /usr

Model: ATA ST3000DM001-9YN1 (scsi)
Disk /dev/sda: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  1000GB  987GB                      raid
 3      1000GB  2000GB  1000GB                     raid
 4      2000GB  3001GB  1001GB                     raid

  VG      #PV #LV #SN Attr   VSize   VFree
  vgsys03   2   6   0 wz--n- 931.31g 906.31g
project/sys03/filesystem.txt · Zuletzt geändert: 2013/01/05 12:56 von 82.212.50.234