os信息备份

系统版本

1
2
3
4
5
6
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)


# uname -r
3.10.0-957.el7.x86_64

el7是RHEL7系列的,centos7看到

1
2
❯ uname -r
6.1.0-0.deb11.7-amd64

debian11

图形界面

xface

1
2
3
4
5
6
7
8
#查看当前启动模式
systemctl get-default

#由命令行模式更改为图形界面模式
systemctl set-default graphical.target

#由图形界面模式更改为命令行模式
systemctl set-default multi-user.target

命令行界面—>图形界面

执行startx命令

图形界面—>命令行界面

Ctrl+Alt+F2

CPU信息

1
❯ sudo dmidecode | grep -A16 "Memory Device" | grep 'Type:\|Speed\|Size:' |grep -v "Unknown\|Installed\|Range"

Size: 8 GB
Type: DDR4
Speed: 2400 MT/s
Size: 8 GB
Type: DDR4
Speed: 2400 MT/s

CPU主频:

1
❯ sudo dmidecode -t processor | grep "Speed"

Max Speed: 8300 MHz

Current Speed: 2700 MHz

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ lscpu | grep "MHz"
CPU MHz: 3400.159
CPU max MHz: 3800.0000
CPU min MHz: 800.0000
❯ cat /proc/cpuinfo | grep "cpu MHz"
cpu MHz : 3399.938
cpu MHz : 3471.310
cpu MHz : 3446.992
cpu MHz : 3497.726
cpu MHz : 3445.833
cpu MHz : 3496.419
cpu MHz : 3448.879
cpu MHz : 943.164
1
2
❯ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
3800000

引导

启动

1
2
3
4
5
6
7
8
#选择系统图
/usr/share/grub/themes/breeze
#themes配置
/usr/share/grub/themes/breeze/theme.txt


#启动图
/usr/share/images/desktop-base/desktop-grub.png

双系统boot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cs@debian:~$ sudo tree /boot/efi/EFI -L 2
/boot/efi/EFI
├── Boot
│   └── bootx64.efi
├── debian
│   ├── BOOTX64.CSV
│   ├── fbx64.efi
│   ├── grub.cfg
│   ├── grubx64.efi
│   ├── mmx64.efi
│   └── shimx64.efi
└── Microsoft
└── Boot

4 directories, 7 files

1
2
3
4
5
6
7
8
9
10
cs@debian:~$ sudo update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-21-amd64
Found initrd image: /boot/initrd.img-5.10.0-21-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done

https://www.cnblogs.com/coding-my-life/p/12817690.html

备份

步骤

新盘先装系统分好盘

新系统内核与老系统版本一致

1
2
❯ uname -r
6.1.0-0.deb11.6-amd64

查看安装的内核

1
dpkg --get-selections | grep linux-image

卸载无用内核

1
2
sudo apt-get purge linux-image-4.2.0-16-generic
sudo apt autoremove

建议先卸载比较老的内核,不需要的可以删除。正常情况下,除正在使用的其它的都可以卸载,但是由于考虑到刚升级的版本可能不稳定,所以最好保留1个旧版本备用。

进入原系统

备份目录,解压到新系统目录

1
2
3
4
5
6
7
8
9
10
11
12
13
#用户目录配置信息文件
/home/cs$ tar cvpzf cs.tar.gz --exclude=.cache --exclude=cs.tar.gz ./.*

/media/cs/xx/cs$ tar xvpfz cs.tar.gz -C ./

tar -cvpzf ./var.tar.gz --exclude=/var/tmp --exclude=/var/log /var
tar xvpfz var.tar.gz -C /media/cs/xx/var --strip-components 1

tar -cvpzf ./usr.tar.gz /usr
tar xvpfz usr.tar.gz -C /media/cs/xx/usr --strip-components 1

tar -cvpzf ./etc.tar.gz --exclude=/etc/fstab /etc
tar xvpfz etc.tar.gz -C /media/cs/xx/etc --strip-components 1

–exclude 权限问题无法或无需备份的进行过滤文件目录

提前备份新旧系统的2个文件

/etc/fstab(fstab 盘符uuid不一样)

/boot/grub/grub.cfg (grub.cfg 盘符uuid不一样)

登陆新系统验证

grub

win

win os u盘修复win引导在esp盘

linux

无法进入grub

linux u盘 引导修复 ,主要是挂载目录到shell环境

grub>

在救援模式下只有很少的命令可以用:set , ls , insmod , root , prefix

  • ls 查看设备
  • set 查看环境变量,这里可以查看启动路径和分区。
  • root 指定用于启动系统的分区,在救援模式下设置grub启动分区
  • prefix 设定grub启动路径
  • insmod 加载模块normal

1
2
3
4
5
6
7
grub rescue>set root=(hd0,gpt4) 

grub rescue>set prefix=(hd0,gpt4)/boot/grub

grub rescue>insmod normal #启动normal启动

grub rescue>normal #之后你就会看到熟悉的启动菜单栏了

出现选择界面,进入系统

1
2
3
4
5
6
7
8
9
10
11
12
❯ update-grub
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/breeze/theme.txt
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-6.1.0-0.deb11.6-amd64
Found initrd image: /boot/initrd.img-6.1.0-0.deb11.6-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p6@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done

直接操作 update-grub 会导致每次都是 grub> ,重新设置启动 grub-install

grub-install /dev/nvme0n1p1

在进入系统之后,通过grub-install脚本进行安装grub,原先在/boot/grub下的stage文件都删除也没关系,该脚本每次执行都会删除这些文件的。

参数(可省略) 含义
–root-directory 在指定目录安装GRUB镜像
–grub-shell 使用指定文件作为GRUB Shell
–no-floppy 不探测任何软盘驱动器

https://www.cnblogs.com/zhengah/p/4238396.html

new

old

盘/etc/fstab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
❯ sudo lsblk -o name,uuid
NAME UUID
sda
├─sda1 70BE7BF5BE7BB1E8
├─sda2 0FE407890FE40789
├─sda3 b519f517-5f11-4108-8601-e456e3da4fd1
├─sda4 0CFA1DD20CFA1DD2
└─sda5 2006966506963BAA
sdb
├─sdb1 0003DFF700005BA6
├─sdb2 FF6E-1E1A
├─sdb3 fe04554c-3dae-42e5-9fd5-5ddda44d2f1c
├─sdb4 5f92ed02-f45d-49e5-b245-09f7447eac24
├─sdb5 5cb263cd-27a3-4ab2-9090-7417f4c80536
├─sdb6 abca56cf-7ab5-4c4a-a5ab-f4b2ebdc0c82
└─sdb7 f26d54f8-1746-47a9-8805-3d339062ab3a
nvme0n1
├─nvme0n1p1 8aef5178-364f-47de-9016-3b3bb254aadd
├─nvme0n1p2 ff3aedfa-1448-4161-95fb-3b43fddf4506
├─nvme0n1p3 8c8a753d-b3f4-45ee-b2a8-629c13f4c18e
├─nvme0n1p4 a40908d9-e0e9-4d17-8aad-d7e1a1f90730
├─nvme0n1p5 bb259291-c221-4e34-b422-663e0bea289e
└─nvme0n1p6 E509-52C5

分区

分配未使用的分区

sudo fdisk /dev/nvme0n1

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It’s recommended to umount all file systems, and swapoff all swap
partitions on this disk.

Command (m for help): F

Unpartitioned space /dev/nvme0n1: 503.79 GiB, 540936314368 bytes, 1056516239 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
-
Start End Sectors Size
2850512896 3907029134 1056516239 503.8G
-
Command (m for help): n
Partition number (11-128, default 11): 默认按回车
First sector (2850512896-3907029134, default 2850512896): 默认按回车
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2850512896-3907029134, default 3907028991): +150G

Created a new partition 11 of type ‘Linux filesystem’ and of size 150 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

##不保存,退出q

Command (m for help): q

新分区分配lvm
创建pv,vg,lv
❯ sudo fdisk /dev/nvme0n1 -l
Disk /dev/nvme0n1: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: KINGSTON SNV2S2000G                     
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: gpt
Disk identifier: 567141B0-39E4-467E-B67D-61B05D225406

Device Start End Sectors Size Type /dev/nvme0n1p1 2048 117186559 117184512 55.9G Linux filesystem /dev/nvme0n1p2 117186560 234373119 117186560 55.9G Linux filesystem /dev/nvme0n1p3 234373120 644530175 410157056 195.6G Linux filesystem /dev/nvme0n1p4 644530176 1386717183 742187008 353.9G Linux filesystem /dev/nvme0n1p5 1386717184 1402341375 15624192 7.5G Linux swap /dev/nvme0n1p6 1402341376 1403473919 1132544 553M EFI System /dev/nvme0n1p7 1403473920 1571248127 167774208 80G Microsoft basic data /dev/nvme0n1p8 1571248128 1739020287 167772160 80G Linux filesystem /dev/nvme0n1p9 1739020288 2263308287 524288000 250G Linux filesystem /dev/nvme0n1p10 2263308288 2850512895 587204608 280G Microsoft basic data /dev/nvme0n1p11 2850512896 3102171135 251658240 120G Linux filesystem ❯ sudo pvcreate /dev/nvme0n1p11 Physical volume "/dev/nvme0n1p11" successfully created. ❯ sudo vgcreate vgoss /dev/nvme0n1p11 Volume group "vgoss" successfully created ❯ sudo lvcreate -l 100%VG -n lv-oss vgoss Logical volume "lv-oss" created. ❯ sudo lvdisplay --- Logical volume --- LV Path /dev/vgoss/lv-oss LV Name lv-oss VG Name vgoss LV UUID RRAqG8-8ReS-RixP-KeCR-DbjH-C6we-NN35wv LV Write Access read/write LV Creation host, time debian, 2024-09-06 22:23:09 +0800 LV Status available # open 0 LV Size <120.00 GiB Current LE 30719 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:2

lvm

sudo pvcreate /dev/sda6 分区创建物理卷
WARNING: dos signature detected on /dev/sda6 at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sda6.
Physical volume “/dev/sda6” successfully created.
sudo vgcreate vgdata /dev/sda6
Volume group “vgdata” successfully created
sudo vgdisplay
— Volume group —
VG Name vgdata
System ID
Format lvm2

…..

❯ sudo vgcreate vgdata /dev/sda6
A volume group called vgdata already exists.
sudo lvcreate -l 100%VG -n lv-images vgdata 将新加的硬盘卷组的空间百分百创建为逻辑卷
Logical volume “lv-images” created.
sudo lvdisplay
— Logical volume —
LV Path /dev/vgdata/lv-images
LV Name lv-images
VG Name vgdata
LV UUID ZesxQK-m3gy-Gd2v-mvtl-VzOw-bcjn-5HHyvD
LV Write Access read/write
LV Creation host, time debian, 2024-08-25 16:36:06 +0800
LV Status available

…..

❯ sudo mkfs.xfs /dev/vgdata/lv-images
meta-data=/dev/vgdata/lv-images isize=512 agcount=4, agsize=7910656 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=31642624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

….

扩展卷组 vgextend

扩展卷组以包含新的物理卷

vgextend
vg添加
❯ sudo vgextend vgdata /dev/sda3
Volume group "vgdata" successfully extended

❯ sudo lvcreate -l 100%VG -n lv-kvm vgdata Reducing 100%VG to remaining free space <108.61 GiB in VG. Logical volume "lv-kvm" created.
扩展逻辑卷 lvextend
1
2
3
sudo lvextend -l +100%FREE /dev/VolumeGroupName/LogicalVolumeName
#20G
sudo lvextend -L +20G /dev/VolumeGroupName/LogicalVolumeName
减小

调整文件系统大小

ext4

1
sudo resize2fs /dev/VolumeGroupName/LogicalVolumeName

xfs

1
sudo xfs_growfs /dev/VolumeGroupName/LogicalVolumeName
减小 ext4
1
2
sudo umount /dev/mapper/VolumeGroupName-LogicalVolumeName
sudo resize2fs /dev/mapper/VolumeGroupName-LogicalVolumeName NewSize
lvreduce 撤回

你只是想要撤销 lvextend 操作,并且没有对逻辑卷进行任何写操作(即没有使用新增的空间),你可以简单地使用 lvreduce 命令将逻辑卷缩小到原来的大小

size 大小

1
sudo lvreduce -L NewSize /dev/VolumeGroupName/LogicalVolumeName  #谨慎操作

PE大小

你不确定逻辑卷的 PE 大小,你可以使用 pvdisplaylvdisplay 命令来查看这些信息

1
sudo lvreduce -l NewLEs /dev/VolumeGroupName/LogicalVolumeName   #谨慎操作

❯ sudo lvdisplay
— Logical volume —
LV Path /dev/vgoss/lv-oss
LV Name lv-oss
VG Name vgoss
LV UUID RRAqG8-8ReS-RixP-KeCR-DbjH-C6we-NN35wv
LV Write Access read/write
LV Creation host, time debian, 2024-09-06 22:23:09 +0800
LV Status available
# open 1
LV Size <120.00 GiB
Current LE 30719 #PE
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 254:2

格式化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
❯ sudo mkfs.xfs /dev/sda6
mkfs.xfs: /dev/sda6 appears to contain an existing filesystem (ext4).
mkfs.xfs: Use the -f option to force overwrite.
❯ sudo mkfs.xfs -f /dev/sda6
meta-data=/dev/sda6 isize=512 agcount=4, agsize=7910912 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=31643648, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

new

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p1 during installation
UUID=8aef5178-364f-47de-9016-3b3bb254aadd / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/nvme0n1p6 during installation
UUID=E509-52C5 /boot/efi vfat umask=0077 0 1
# /home was on /dev/nvme0n1p3 during installation
UUID=8c8a753d-b3f4-45ee-b2a8-629c13f4c18e /home ext4 defaults 0 2
# /opt was on /dev/nvme0n1p4 during installation
UUID=a40908d9-e0e9-4d17-8aad-d7e1a1f90730 /opt ext4 defaults 0 2
# /usr was on /dev/nvme0n1p2 during installation
UUID=ff3aedfa-1448-4161-95fb-3b43fddf4506 /usr ext4 defaults 0 2
# swap was on /dev/nvme0n1p5 during installation
UUID=bb259291-c221-4e34-b422-663e0bea289e none swap sw 0 0
# /data was on /dev/sdb3 during installation

old

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda7 during installation
UUID=f26d54f8-1746-47a9-8805-3d339062ab3a / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda2 during installation
UUID=FF6E-1E1A /boot/efi vfat umask=0077 0 1
# /home was on /dev/sda6 during installation
UUID=abca56cf-7ab5-4c4a-a5ab-f4b2ebdc0c82 /home ext4 defaults 0 2
# /opt was on /dev/sda4 during installation
UUID=5f92ed02-f45d-49e5-b245-09f7447eac24 /opt ext4 defaults 0 2
# /usr was on /dev/sda5 during installation
UUID=5cb263cd-27a3-4ab2-9090-7417f4c80536 /usr ext4 defaults 0 2
# swap was on /dev/sda3 during installation
UUID=fe04554c-3dae-42e5-9fd5-5ddda44d2f1c none swap sw 0 0
# /data was on /dev/sdb3 during installation
UUID=b519f517-5f11-4108-8601-e456e3da4fd1 /home/cs/data xfs defaults 0 2

upgrade

更新本地包索引

1
sudo apt update

安装可用更新

1
2
3
$ sudo apt upgrade
$ sudo apt full-upgrade
$ sudo apt --purge autoremove

重启

1
sudo reboot

$ sudo apt-mark showhold | more
$ sudo apt-mark unhold

备份源

1
2
3
4
5
sudo cp -v /etc/apt/sources.list /opt/sources.list-bakup-debian11

sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list

sudo apt update

升级系统

1
sudo apt full-upgrade

Pres-q-to-Proceed-further-Debian-Upgrade 按 q 继续下一步

Keep-Local-Verison-SSHD-During-Debian-Upgrade

Keep-Local-Grub-Version-During-Debian-Upgrade

重启

1
sudo reboot

error

mdadm: no arrays found in config file or automatically

1
2
3
#debian 
sudo rm /etc/initramfs-tools/conf.d/resume
sudo update-initramfs -u

This is the initramfs configuration where mdadm.conf is copied and some magic happens to start the array. Did you create a md raid array or use btrfs array options? If you used mdadm then mdadm --detail --scan >> /etc/mdadm/mdadm.conf will add the array configuration and update-initramfs -u -k all will create a new initramfs image. The resume entry is in /etc/initramfs-tools/conf.d/resume if you want to change that (i had to change it to ‘none’ for encrypted swap).

https://www.reddit.com/r/debian/comments/h8b0am/dell_optiplex_390_gets_stuck_on_mdadm_no_arrays/

点击打赏
文章目录
  1. 1. 系统版本
  2. 2. 图形界面
    1. 2.1. CPU信息
  3. 3. 引导
    1. 3.1. 启动
    2. 3.2. 双系统boot
  4. 4. 备份
    1. 4.1. 步骤
      1. 4.1.1. 新盘先装系统分好盘
      2. 4.1.2. 进入原系统
      3. 4.1.3. 登陆新系统验证
    2. 4.2. grub
      1. 4.2.1. win
      2. 4.2.2. linux
        1. 4.2.2.1. 无法进入grub
        2. 4.2.2.2. grub>
      3. 4.2.3. new
      4. 4.2.4. old
    3. 4.3. 盘/etc/fstab
      1. 4.3.1. 分区
        1. 4.3.1.1. 分配未使用的分区
      2. 4.3.2. lvm
        1. 4.3.2.1. 扩展卷组 vgextend
        2. 4.3.2.2. 扩展逻辑卷 lvextend
        3. 4.3.2.3. 减小
          1. 4.3.2.3.1. 减小 ext4
          2. 4.3.2.3.2. lvreduce 撤回
      3. 4.3.3. new
      4. 4.3.4. old
  5. 5. upgrade
    1. 5.1. 更新本地包索引
    2. 5.2. 安装可用更新
    3. 5.3. 重启
    4. 5.4. 备份源
    5. 5.5. 升级系统
    6. 5.6. 重启
  6. 6. error
    1. 6.1. mdadm: no arrays found in config file or automatically
载入天数...载入时分秒... ,