新系統調整

  1. 掛載新的隨身碟,根目錄在 /mnt/root。
    [root@dywmac ~]# mount /dev/mapper/vg_crt-root /mnt/root/
    [root@dywmac ~]# mount /dev/mapper/vg_crt-home /mnt/root/home/
    [root@dywmac ~]# mount /dev/sdc1 /mnt/root/boot/
    
  2. 光是將檔案複製到新的隨身碟,通常是無法開機,至少必須先將 grub 安裝到新的隨身碟,重新產生 device.map 才能開機。
    [root@dywmac ~]# grub-install --recheck --root-directory=/mnt/root/ /dev/sdc
    Probing devices to guess BIOS drives. This may take a long time.
    Installation finished. No error reported.
    This is the contents of the device map /mnt/boot//boot/grub/device.map.
    Check if this is correct or not. If any of the lines is incorrect,
    fix it and re-run the script `grub-install'.
    
    (fd0)   /dev/fd0
    (hd0)   /dev/sda
    (hd1)   /dev/sdc
    
  3. 由於各分割區都是新建立的,UUID 不可能相同,掛載表中使用 UUID 掛載的都要修改,例如查詢新隨身碟 /dev/sdc1 分割區的 UUID,並修改 fstab 掛載表使其一致,否則開機時無法掛載。
    [root@dywmac ~]# blkid /dev/sdc1
    /dev/sdc1: UUID="d98d1c88-504d-4dc4-9eb5-d557e3f28cfe" TYPE="ext4" 
    [root@dywmac ~]# vim /mnt/root/etc/fstab 
    [root@dywmac ~]# grep boot /mnt/root/etc/fstab
    UUID=d98d1c88-504d-4dc4-9eb5-d557e3f28cfe /boot ext4  defaults   1 2
    
  4. 在新系統的根目錄產生隱藏檔 .autorelabel,否則開機後因 selinux 管制而無法登。
    [root@dywmac ~]# touch /mnt/root/.autorelabel
    
  5. 卸載隨身碟,取出隨身碟到其他電腦開機。
    [root@dywmac ~]# umount /mnt/*