优化grub分区挂载脚本
This commit is contained in:
parent
42e5cc3d99
commit
80df96b8b2
|
@ -79,6 +79,8 @@ mount_fstab(){
|
|||
|
||||
# 将/usr/share/initramfs-tools/scripts/local-bottom/kybackup脚本放到/usr/share/initramfs-tools/scripts/init-bottom下后,在备份还原前就已经mount了各个分区(bind的没有mount)
|
||||
echo "rw mode remount $fstab_path begin"
|
||||
local mounted_path=
|
||||
local tmp_path=
|
||||
cat "$fstab_path" | grep -Ev "^#" | awk '{print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' |
|
||||
while read device mntdir fstype options dump passno ;
|
||||
do
|
||||
|
@ -92,8 +94,8 @@ mount_fstab(){
|
|||
#virtual or network filesystems
|
||||
([ none = "$mntdir" ] || [ yes = $(is_remote $fstype) ]) && continue
|
||||
|
||||
#swap or backup分区,backup分区后面单独挂载
|
||||
([ swap = "$fstype" ] || [ /backup = "$mntdir" ]) && continue
|
||||
#swap or backup分区,backup分区后面单独挂载,根分区已挂载
|
||||
([ swap = "$fstype" ] || [ /backup = "$mntdir" ] || [ / = "$mntdir" ]) && continue
|
||||
|
||||
#not system partition
|
||||
#[ no = $(is_system_partition $mntdir) ] && continue
|
||||
|
@ -101,12 +103,18 @@ mount_fstab(){
|
|||
#去掉首字符'/'
|
||||
#mntdir_name=$(echo $mntdir | sed 's:^/::g')
|
||||
#target_mntdir="/$(echo $mntdir_name | sed 's:/:-:g').orig"
|
||||
target_mntdir=${rootmnt}${mntdir}
|
||||
target_mntdir=${rootmnt}${mntdir}
|
||||
mounted_path=
|
||||
tmp_path=
|
||||
mkdir -p "$target_mntdir"
|
||||
tmp_path=$target_mntdir
|
||||
mounted_path=$(mount | awk -v v_path=${tmp_path} '{ if($3 == v_path) print $3 }')
|
||||
if [[ $options =~ bind ]] ; then
|
||||
# bind挂载的就不再挂了
|
||||
echo "mount -o $options ${rootmnt}${device} $target_mntdir"
|
||||
mount -o $options "${rootmnt}${device}" "$target_mntdir"
|
||||
elif [ "x" == "x"${mounted_path} ]; then
|
||||
echo "mount -n -t $fstype -o $mntopts $device $target_mntdir"
|
||||
mount -n -t $fstype -o $mntopts $device "$target_mntdir"
|
||||
else
|
||||
# echo "mount -n -t $fstype -o $mntopts $device $target_mntdir"
|
||||
# mount -n -t $fstype -o $mntopts $device "$target_mntdir"
|
||||
|
|
Loading…
Reference in New Issue