ArchLinux下通过Grub2引导进入GPartedLive动态调整分区大小

本文介绍了如何在ArchLinux中利用Grub2引导进入GPartedLive,动态调整分区大小。详细步骤包括下载GPartedLive,解压到boot目录,创建自定义Grub菜单文件,编辑启动菜单,备份并生成新的grub.cfg,最后通过新增菜单项进入GPartedLive进行分区调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ArchLinux下通过Grub2引导进入GPartedLive动态调整分区大小

版本:
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# cat /proc/version
Linux version 3.7.9-2-ARCH (tobias@T-POWA-LX) (gcc version 4.7.2 (GCC) ) #1 SMP PREEMPT Mon Feb 25 12:04:25 CET 2013
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

下载gparted live文件并解压,注意这里的boot是单独分区
(http://voxel.dl.sourceforge.net/project/gparted/gparted-live-stable/0.14.1-6/gparted-live-0.14.1-6-amd64.zip)
unzip gparted-live-0.14.1-6-amd64.zip -d /boot/gpartedlive

调整分区列表,计划将根分区减小10GiB,/var分区增加10GiB
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# df -h | grep sd
/dev/sda2                                               40G  5.3G   33G  14% /
/dev/sda3                                              9.9G  2.6G  6.8G  28% /var
/dev/sda1                                             1008M  199M  758M  21% /boot
/dev/sda6                                              405G  338G   47G  88% /home
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

复制一份自定义grub菜单文件用做gparted live启动菜单
cd /etc/grub.d/
cp -av 41_custom 50_gpartedlive

┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# ll
total 64
-rwxr-xr-x 1 root root  7704 Jun 29  2012 00_header
-rwxr-xr-x 1 root root 10447 Jun 29  2012 10_linux
-rwxr-xr-x 1 root root 10049 Jun 29  2012 20_linux_xen
-rwxr-xr-x 1 root root   899 Jun 29  2012 20_memtest86+
-rwxr-xr-x 1 root root  9343 Jun 29  2012 30_os-prober
-rwxr-xr-x 1 root root   214 Jun 29  2012 40_custom
-rwxr-xr-x 1 root root   216 Jun 29  2012 41_custom
-rwxr-xr-x 1 root root   566 Mar  3 17:59 50_gpartedlive
-rw-r--r-- 1 root root   483 Jun 29  2012 README
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

编辑gparted live启动菜单文件
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# vim 50_gpartedlive
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# cat 50_gpartedlive
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
# echo "Adding GParted Live 0.14.1-6 (03-Mar-2013)" >&2
menuentry "GParted Live 0.14.1-6 (03-Mar-2013)" {
set root='hd0,msdos1'
linux /gpartedlive/live/vmlinuz boot=live config union=aufs noswap noprompt vga=788 ip=frommedia live-media-path=/gpartedlive/live bootfrom=/dev/sda1 toram=filesystem.squashfs
initrd /gpartedlive/live/initrd.img
}
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

备份现有grub.cfg
cp /boot/grub/grub.cfg /boot/grub/grub.cfg_03mar2013

重新生成grub.cfg
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
done
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

检查新的grub.cfg
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─# tail -n 15 /boot/grub/grub.cfg
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/50_gpartedlive ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
# echo "Adding GParted Live 0.14.1-6 (03-Mar-2013)" >&2
menuentry "GParted Live 0.14.1-6 (03-Mar-2013)" {
set root='hd0,msdos1'
linux /gpartedlive/live/vmlinuz boot=live config union=aufs noswap noprompt vga=788 ip=frommedia live-media-path=/gpartedlive/live bootfrom=/dev/sda1 toram=filesystem.squashfs
initrd /gpartedlive/live/initrd.img
}
### END /etc/grub.d/50_gpartedlive ###
┌─[root@tp]─[/etc/grub.d]─[9+0]─[99%=]
└─#

重启并选择新增的菜单"GParted Live 0.14.1-6 (03-Mar-2013)"进入gparted live系统,进行具体的分区大小调整,全是类似PQ Magic的图形化操作,这里不再详述。

调整完后,重启,检查结果
┌─[root@tp]─[~]─[0+1]─[99%=]
└─# df -h | grep sd
/dev/sda2        30G  5.1G   23G  19% /
/dev/sda6       405G  338G   47G  88% /home
/dev/sda1      1008M  199M  758M  21% /boot
/dev/sda3        20G  2.6G   17G  14% /var
┌─[root@tp]─[~]─[0+1]─[99%=]
└─#

REF:
1. Gparted-Live
https://wiki.archlinux.org/index.php/Gparted-Live
2. Manually adding/removing entries to Grub 2 Menu
http://ubuntuguide.net/manually-addingremoving-entries-to-grub-2-menu
3. GRUB2 (简体中文)
https://wiki.archlinux.org/index.php/GRUB2_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值