復原檔案

  1. losetup 卸除 /dev/loop0。
    [root@controller src]# losetup -d /dev/loop0
    
  2. 先查看第一及第二個分割的 start section,分別是 2048 及 6144。
    [root@controller src]# fdisk -l crtefi15g-20190112.img
    
    Disk crtefi15g-20190112.img: 15.7 GB, 15728640000 bytes, 30720000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x55654248
    
                     Device Boot      Start         End      Blocks   Id  System
    crtefi15g-20190112.img1            2048        6143        2048   ef  EFI (FAT-12/16/32)
    crtefi15g-20190112.img2   *        6144      329727      161792   83  Linux
    crtefi15g-20190112.img3          329728    29689855    14680064   8e  Linux LVM
    
  3. 將第一個分割區掛載在 /mnt/efi,第二個分割區掛載在 /mnt/boot,其中 offset=1048576 及 3145728 分別是 2048 及 6144 乘以 512 bytes。
    [root@controller src]# mount -oloop,offset=1048576 crtefi15g-20190112.img /mnt/efi
    [root@controller src]# mount -oloop,offset=3145728 crtefi15g-20190112.img /mnt/boot
    [root@controller src]# df -h /mnt/*
    Filesystem               Size  Used Avail Use% Mounted on
    /dev/loop2               150M  1.6M  140M   2% /mnt/boot
    /dev/loop1               2.0M     0  2.0M   0% /mnt/efi
    
  4. 將原先備份的資料複製回去。
    [root@controller src]# cp -a crtefi/efi/* /mnt/efi/
    [root@controller src]# cp -a crtefi/boot/* /mnt/boot/
    [root@controller src]# df -h /mnt/{efi,boot}
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop1      2.0M  264K  1.8M  14% /mnt/efi
    /dev/loop2      150M  117M   26M  83% /mnt/boot
    
  5. 卸載。
    [root@controller src]# umount /mnt/{efi,boot}