压缩系统文件
tar -cvpzf /home/scr/ftp_dir/bak/sysbak_2019-04-11_all-but-personal-data.tgz --exclude=/dev --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/home/scr/Music --exclude=/home/scr/Data --exclude=/home/scr/Pictures --exclude=/home/scr/Desktop --exclude=/home/scr/Projects --exclude=/home/scr/Documents --exclude=/home/scr/ptp-bin --exclude=/home/scr/Downloads --exclude=/home/scr/Public --exclude=/home/scr/Templates --exclude=/home/scr/eclipse-workspace --exclude=/home/scr/seaborn-data --exclude=/home/scr/Videos --exclude=/home/scr/examples.desktop --exclude=/home/scr/shadowsocksR.log --exclude=/home/scr/vpnPAC --exclude=/home/scr/ftp_dir / > /home/scr/ftp_dir/bak/sysbak_2019-04-11_log.txt
记录新系统信息
示例1
- uuid uuid 和 fstat、grub.conf的uuid对应 ``` (CMIP) scr@shencr:~$ ls /dev/disk/by-uuid 07d4d66a-2928-4bea-835e-d9f97ddedf41 2018-07-25-03-21-56-00
与下面的uuid没有关系?
(CMIP) scr@scr-CMIP-2:~/ftp_dir/bak$ blkid /dev/sda1: UUID=”nBK6M8-ynl1-feuy-ZSc1-Hgl9-4NZO-0v7iOG” TYPE=”LVM2_member” PARTUUID=”97bbece1-01” /dev/loop0: TYPE=”squashfs” /dev/loop1: TYPE=”squashfs” /dev/loop2: TYPE=”squashfs” /dev/loop3: TYPE=”squashfs” /dev/loop4: TYPE=”squashfs” /dev/loop5: TYPE=”squashfs” /dev/loop6: TYPE=”squashfs” /dev/loop7: TYPE=”squashfs” /dev/loop8: TYPE=”squashfs” /dev/loop9: TYPE=”squashfs” /dev/loop10: TYPE=”squashfs” /dev/loop11: TYPE=”squashfs” /dev/loop12: TYPE=”squashfs” /dev/loop13: TYPE=”squashfs” /dev/loop14: TYPE=”squashfs” /dev/loop15: TYPE=”squashfs” /dev/loop16: TYPE=”squashfs” /dev/loop17: TYPE=”squashfs” /dev/sr0: UUID=”2018-07-25-03-21-56-00” LABEL=”Ubuntu 18.04.1 LTS amd64” TYPE=”iso9660” PTUUID=”663eb4c4” PTTYPE=”dos”
1. fdisk
(CMIP) scr@shencr:~$ sudo fdisk -l root@scr-CMIP-2:~# sudo fdisk -l
……
Disk /dev/sda: 1000 GiB, 1073741824000 bytes, 2097152000 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 Disklabel type: dos Disk identifier: 0x71e1fb1e
Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2097149951 2097147904 1000G 83 Linux
root@scr-CMIP-2:~# df -lh Filesystem Size Used Avail Use% Mounted on udev 4.9G 0 4.9G 0% /dev tmpfs 999M 1.9M 997M 1% /run /dev/sda1 984G 110G 824G 12% / tmpfs 4.9G 16M 4.9G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup /dev/loop0 87M 87M 0 100% /snap/core/4917 /dev/loop2 35M 35M 0 100% /snap/gtk-common-themes/319 /dev/loop1 15M 15M 0 100% /snap/gnome-logs/37 /dev/loop3 2.4M 2.4M 0 100% /snap/gnome-calculator/180 /dev/loop5 3.8M 3.8M 0 100% /snap/gnome-system-monitor/51 /dev/loop4 13M 13M 0 100% /snap/gnome-characters/103 /dev/loop6 141M 141M 0 100% /snap/gnome-3-26-1604/70 tmpfs 999M 28K 999M 1% /run/user/121 tmpfs 999M 56K 999M 1% /run/user/1000 /dev/sr0 1.9G 1.9G 0 100% /media/scr/Ubuntu 18.04.1 LTS amd64 /dev/loop7 90M 90M 0 100% /snap/core/6673 /dev/loop8 54M 54M 0 100% /snap/core18/782 /dev/loop9 1.0M 1.0M 0 100% /snap/gnome-logs/57 /dev/loop10 4.2M 4.2M 0 100% /snap/gnome-calculator/352 /dev/loop11 3.8M 3.8M 0 100% /snap/gnome-system-monitor/70 /dev/loop12 36M 36M 0 100% /snap/gtk-common-themes/1198 /dev/loop13 15M 15M 0 100% /snap/gnome-characters/206 /dev/loop14 141M 141M 0 100% /snap/gnome-3-26-1604/82 /dev/loop15 144M 144M 0 100% /snap/gnome-3-28-1804/23 /dev/loop16 15M 15M 0 100% /snap/gnome-characters/254 /dev/loop17 4.2M 4.2M 0 100% /snap/gnome-calculator/406
3. 备份fstab文件
root@scr-CMIP-2:~# cp /etc/fstab /home/scr/ftp_dir/bak/
/etc/fstab: static file system information.
#
Use ‘blkid’ to print the universally unique identifier for a
device; this may be used with UUID= as a more robust way to name devices
that works even if disks are added and removed. See fstab(5).
#
/ was on /dev/sda1 during installation
UUID=07d4d66a-2928-4bea-835e-d9f97ddedf41 / ext4 errors=remount-ro 0 1 /swapfile none swap sw 0 0
## 示例2
scr@scr-CMIP-3:~$ ls /dev/disk/by-uuid/ cec68fe1-82e9-4bf9-adbc-7b0265650f9d ee0be8f1-c0a3-4d60-aeea-43fbf73067fd
scr@scr-CMIP-3:~$ blkid /dev/loop0: TYPE=”squashfs” /dev/loop1: TYPE=”squashfs” /dev/loop2: TYPE=”squashfs” /dev/loop3: TYPE=”squashfs” /dev/loop4: TYPE=”squashfs” /dev/loop5: TYPE=”squashfs” /dev/loop6: TYPE=”squashfs” /dev/sda1: UUID=”ee0be8f1-c0a3-4d60-aeea-43fbf73067fd” TYPE=”ext4” PARTUUID=”7d612abb-01” /dev/sda2: UUID=”cec68fe1-82e9-4bf9-adbc-7b0265650f9d” TYPE=”ext4” PARTUUID=”7d612abb-02”
scr@scr-CMIP-3:~$ sudo fdisk -l
……
Disk /dev/sda: 1000 GiB, 1073741824000 bytes, 2097152000 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 Disklabel type: dos Disk identifier: 0x7d612abb
Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2097149951 2097147904 1000G 83 Linux /dev/sda2 2097149952 2097151999 2048 1M 83 Linux ```
将备份好的包拷贝到新电脑上,展开:(可在桌面环境下进行)
tar -xvpzf /home/scr/ftp_dir/bak/sysbak_2019-04-11_all-but-personal-data -C /
此刻新电脑无法正常启动,需修正 (从liveCD或USB或whatever什么玩意启动)
原因在于UUID不匹配,因此: 替换覆盖好的 /etc/fstab 中的内容为包含正确 UUID (新电脑)的值,如有其它想要自动加载的内容,也应一并修改成功 替换覆盖好的 /boot/grub/grub.cfg (menu.lst) 中的内容为正确的 UUID 以及 分区符号 以及可能的sd*错误 (按以上做法应该没有)