set UUID directly when formatting ZFS (#1216)
Signed-off-by: enoch85 <github@hanssonit.se>
This commit is contained in:
Родитель
0d6ab8a7f9
Коммит
6698be0bd0
3
lib.sh
3
lib.sh
|
@ -1232,7 +1232,7 @@ done
|
|||
|
||||
zpool_import_if_missing() {
|
||||
# ZFS needs to be installed
|
||||
if ! is_this_installed libzfs2linux
|
||||
if ! is_this_installed zfsutils-linux
|
||||
then
|
||||
print_text_in_color "$IRed" "This function is only intened to be run if you have ZFS installed."
|
||||
return 1
|
||||
|
@ -1250,6 +1250,7 @@ fi
|
|||
if zpool list -v | grep sdb
|
||||
then
|
||||
# Get UUID
|
||||
check_command partprobe -s
|
||||
if fdisk -l /dev/sdb1 >/dev/null 2>&1
|
||||
then
|
||||
UUID_SDB1=$(blkid -o value -s UUID /dev/sdb1)
|
||||
|
|
|
@ -14,8 +14,7 @@ root_check
|
|||
check_distro_version
|
||||
check_multiverse
|
||||
|
||||
LABEL_=ncdata
|
||||
MOUNT_=/mnt/$LABEL_
|
||||
MOUNT_=/mnt/$POOLNAME
|
||||
|
||||
format() {
|
||||
# umount if mounted
|
||||
|
@ -143,22 +142,22 @@ then
|
|||
msg_box "Formatting your $SYSNAME secondary volume ($DISKTYPE) when you hit OK.
|
||||
|
||||
*** WARNING: ALL YOUR DATA WILL BE ERASED! ***"
|
||||
if zpool list | grep "$LABEL_" > /dev/null
|
||||
if zpool list | grep "$POOLNAME" > /dev/null
|
||||
then
|
||||
check_command zpool destroy "$LABEL_"
|
||||
check_command zpool destroy "$POOLNAME"
|
||||
fi
|
||||
check_command wipefs -a -f "$DISKTYPE"
|
||||
sleep 0.5
|
||||
check_command zpool create -f -o ashift=12 "$LABEL_" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$LABEL_"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$LABEL_"
|
||||
check_command zfs set compression=lz4 "$LABEL_"
|
||||
check_command zfs set sync=standard "$LABEL_"
|
||||
check_command zfs set xattr=sa "$LABEL_"
|
||||
check_command zfs set primarycache=all "$LABEL_"
|
||||
check_command zfs set atime=off "$LABEL_"
|
||||
check_command zfs set recordsize=128k "$LABEL_"
|
||||
check_command zfs set logbias=latency "$LABEL_"
|
||||
check_command zpool create -f -o ashift=12 "$POOLNAME" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$POOLNAME"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$POOLNAME"
|
||||
check_command zfs set compression=lz4 "$POOLNAME"
|
||||
check_command zfs set sync=standard "$POOLNAME"
|
||||
check_command zfs set xattr=sa "$POOLNAME"
|
||||
check_command zfs set primarycache=all "$POOLNAME"
|
||||
check_command zfs set atime=off "$POOLNAME"
|
||||
check_command zfs set recordsize=128k "$POOLNAME"
|
||||
check_command zfs set logbias=latency "$POOLNAME"
|
||||
|
||||
else
|
||||
msg_box "It seems like /dev/$DEVTYPE does not exist.
|
||||
|
@ -176,15 +175,29 @@ format
|
|||
# Do a backup of the ZFS mount
|
||||
if is_this_installed libzfs2linux
|
||||
then
|
||||
if grep -r $LABEL_ /etc/mtab
|
||||
if grep -r $POOLNAME /etc/mtab
|
||||
then
|
||||
install_if_not zfs-auto-snapshot
|
||||
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if UUID is used
|
||||
if zpool list -v | grep "$DEVTYPE"
|
||||
then
|
||||
# Get UUID
|
||||
check_command partprobe -s
|
||||
if fdisk -l /dev/"$DEVTYPE"1 >/dev/null 2>&1
|
||||
then
|
||||
UUID_SDB1=$(blkid -o value -s UUID /dev/"DEVTYPE"1)
|
||||
fi
|
||||
# Export / import the correct way (based on UUID)
|
||||
check_command zpool export "$POOLNAME"
|
||||
check_command zpool import -d /dev/disk/by-uuid/"$UUID_SDB1" "$POOLNAME"
|
||||
fi
|
||||
|
||||
# Success!
|
||||
if grep "$LABEL_" /etc/mtab
|
||||
if grep "$POOLNAME" /etc/mtab
|
||||
then
|
||||
msg_box "$MOUNT_ mounted successfully as a ZFS volume.
|
||||
|
||||
|
@ -192,12 +205,12 @@ Automatic scrubbing is done monthly via a cronjob that you can find here:
|
|||
/etc/cron.d/zfsutils-linux
|
||||
|
||||
Automatic snapshots are taken with 'zfs-auto-snapshot'. You can list current snapshots with:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
http://manpages.ubuntu.com/manpages/focal/man8/zfs-auto-snapshot.8.html
|
||||
|
||||
CURRENT STATUS:
|
||||
$(zpool status $LABEL_)
|
||||
$(zpool status $POOLNAME)
|
||||
|
||||
$(zpool list)"
|
||||
fi
|
||||
|
|
|
@ -14,8 +14,7 @@ root_check
|
|||
check_distro_version
|
||||
check_multiverse
|
||||
|
||||
LABEL_=ncdata
|
||||
MOUNT_=/mnt/$LABEL_
|
||||
MOUNT_=/mnt/$POOLNAME
|
||||
|
||||
format() {
|
||||
# umount if mounted
|
||||
|
@ -77,7 +76,7 @@ exit 1
|
|||
fi
|
||||
|
||||
# Check if ZFS utils are installed
|
||||
install_if_not zfsutils-linux
|
||||
install_if_not zfsutils-linux
|
||||
|
||||
# Check still not mounted
|
||||
#These functions return exit codes: 0 = found, 1 = not found
|
||||
|
@ -122,22 +121,22 @@ then
|
|||
msg_box "Formatting your $SYSNAME secondary volume ($DISKTYPE) when you hit OK.
|
||||
|
||||
*** WARNING: ALL YOUR DATA WILL BE ERASED! ***"
|
||||
if zpool list | grep "$LABEL_" > /dev/null
|
||||
if zpool list | grep "$POOLNAME" > /dev/null
|
||||
then
|
||||
check_command zpool destroy "$LABEL_"
|
||||
check_command zpool destroy "$POOLNAME"
|
||||
fi
|
||||
check_command wipefs -a -f "$DISKTYPE"
|
||||
sleep 0.5
|
||||
check_command zpool create -f -o ashift=12 "$LABEL_" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$LABEL_"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$LABEL_"
|
||||
check_command zfs set compression=lz4 "$LABEL_"
|
||||
check_command zfs set sync=standard "$LABEL_"
|
||||
check_command zfs set xattr=sa "$LABEL_"
|
||||
check_command zfs set primarycache=all "$LABEL_"
|
||||
check_command zfs set atime=off "$LABEL_"
|
||||
check_command zfs set recordsize=128k "$LABEL_"
|
||||
check_command zfs set logbias=latency "$LABEL_"
|
||||
check_command zpool create -f -o ashift=12 "$POOLNAME" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$POOLNAME"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$POOLNAME"
|
||||
check_command zfs set compression=lz4 "$POOLNAME"
|
||||
check_command zfs set sync=standard "$POOLNAME"
|
||||
check_command zfs set xattr=sa "$POOLNAME"
|
||||
check_command zfs set primarycache=all "$POOLNAME"
|
||||
check_command zfs set atime=off "$POOLNAME"
|
||||
check_command zfs set recordsize=128k "$POOLNAME"
|
||||
check_command zfs set logbias=latency "$POOLNAME"
|
||||
|
||||
else
|
||||
msg_box "It seems like /dev/$DEVTYPE does not exist.
|
||||
|
@ -155,15 +154,29 @@ format
|
|||
# Do a backup of the ZFS mount
|
||||
if is_this_installed libzfs2linux
|
||||
then
|
||||
if grep -r $LABEL_ /etc/mtab
|
||||
if grep -r $POOLNAME /etc/mtab
|
||||
then
|
||||
install_if_not zfs-auto-snapshot
|
||||
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if UUID is used
|
||||
if zpool list -v | grep "$DEVTYPE"
|
||||
then
|
||||
# Get UUID
|
||||
check_command partprobe -s
|
||||
if fdisk -l /dev/"$DEVTYPE"1 >/dev/null 2>&1
|
||||
then
|
||||
UUID_SDB1=$(blkid -o value -s UUID /dev/"DEVTYPE"1)
|
||||
fi
|
||||
# Export / import the correct way (based on UUID)
|
||||
check_command zpool export "$POOLNAME"
|
||||
check_command zpool import -d /dev/disk/by-uuid/"$UUID_SDB1" "$POOLNAME"
|
||||
fi
|
||||
|
||||
# Success!
|
||||
if grep "$LABEL_" /etc/mtab
|
||||
if grep "$POOLNAME" /etc/mtab
|
||||
then
|
||||
msg_box "$MOUNT_ mounted successfully as a ZFS volume.
|
||||
|
||||
|
@ -171,12 +184,12 @@ Automatic scrubbing is done monthly via a cronjob that you can find here:
|
|||
/etc/cron.d/zfsutils-linux
|
||||
|
||||
Automatic snapshots are taken with 'zfs-auto-snapshot'. You can list current snapshots with:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
http://manpages.ubuntu.com/manpages/focal/man8/zfs-auto-snapshot.8.html
|
||||
|
||||
CURRENT STATUS:
|
||||
$(zpool status $LABEL_)
|
||||
$(zpool status $POOLNAME)
|
||||
|
||||
$(zpool list)"
|
||||
fi
|
||||
|
|
|
@ -14,8 +14,7 @@ root_check
|
|||
check_distro_version
|
||||
check_multiverse
|
||||
|
||||
LABEL_=ncdata
|
||||
MOUNT_=/mnt/$LABEL_
|
||||
MOUNT_=/mnt/"$POOLNAME"
|
||||
|
||||
format() {
|
||||
# umount if mounted
|
||||
|
@ -122,22 +121,22 @@ then
|
|||
msg_box "Formatting your $SYSNAME secondary volume ($DISKTYPE) when you hit OK.
|
||||
|
||||
*** WARNING: ALL YOUR DATA WILL BE ERASED! ***"
|
||||
if zpool list | grep "$LABEL_" > /dev/null
|
||||
if zpool list | grep "$POOLNAME" > /dev/null
|
||||
then
|
||||
check_command zpool destroy "$LABEL_"
|
||||
check_command zpool destroy "$POOLNAME"
|
||||
fi
|
||||
check_command wipefs -a -f "$DISKTYPE"
|
||||
sleep 0.5
|
||||
check_command zpool create -f -o ashift=12 "$LABEL_" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$LABEL_"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$LABEL_"
|
||||
check_command zfs set compression=lz4 "$LABEL_"
|
||||
check_command zfs set sync=standard "$LABEL_"
|
||||
check_command zfs set xattr=sa "$LABEL_"
|
||||
check_command zfs set primarycache=all "$LABEL_"
|
||||
check_command zfs set atime=off "$LABEL_"
|
||||
check_command zfs set recordsize=128k "$LABEL_"
|
||||
check_command zfs set logbias=latency "$LABEL_"
|
||||
check_command zpool create -f -o ashift=12 "$POOLNAME" "$DISKTYPE"
|
||||
check_command zpool set failmode=continue "$POOLNAME"
|
||||
check_command zfs set mountpoint="$MOUNT_" "$POOLNAME"
|
||||
check_command zfs set compression=lz4 "$POOLNAME"
|
||||
check_command zfs set sync=standard "$POOLNAME"
|
||||
check_command zfs set xattr=sa "$POOLNAME"
|
||||
check_command zfs set primarycache=all "$POOLNAME"
|
||||
check_command zfs set atime=off "$POOLNAME"
|
||||
check_command zfs set recordsize=128k "$POOLNAME"
|
||||
check_command zfs set logbias=latency "$POOLNAME"
|
||||
|
||||
else
|
||||
msg_box "It seems like /dev/$DEVTYPE does not exist.
|
||||
|
@ -155,15 +154,29 @@ format
|
|||
# Do a backup of the ZFS mount
|
||||
if is_this_installed libzfs2linux
|
||||
then
|
||||
if grep -r $LABEL_ /etc/mtab
|
||||
if grep -r $POOLNAME /etc/mtab
|
||||
then
|
||||
install_if_not zfs-auto-snapshot
|
||||
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if UUID is used
|
||||
if zpool list -v | grep "$DEVTYPE"
|
||||
then
|
||||
# Get UUID
|
||||
check_command partprobe -s
|
||||
if fdisk -l /dev/"$DEVTYPE"1 >/dev/null 2>&1
|
||||
then
|
||||
UUID_SDB1=$(blkid -o value -s UUID /dev/"DEVTYPE"1)
|
||||
fi
|
||||
# Export / import the correct way (based on UUID)
|
||||
check_command zpool export "$POOLNAME"
|
||||
check_command zpool import -d /dev/disk/by-uuid/"$UUID_SDB1" "$POOLNAME"
|
||||
fi
|
||||
|
||||
# Success!
|
||||
if grep "$LABEL_" /etc/mtab
|
||||
if grep "$POOLNAME" /etc/mtab
|
||||
then
|
||||
msg_box "$MOUNT_ mounted successfully as a ZFS volume.
|
||||
|
||||
|
@ -171,12 +184,12 @@ Automatic scrubbing is done monthly via a cronjob that you can find here:
|
|||
/etc/cron.d/zfsutils-linux
|
||||
|
||||
Automatic snapshots are taken with 'zfs-auto-snapshot'. You can list current snapshots with:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
'sudo zfs list -t snapshot'.
|
||||
Manpage is here:
|
||||
http://manpages.ubuntu.com/manpages/focal/man8/zfs-auto-snapshot.8.html
|
||||
|
||||
CURRENT STATUS:
|
||||
$(zpool status $LABEL_)
|
||||
$(zpool status $POOLNAME)
|
||||
|
||||
$(zpool list)"
|
||||
fi
|
||||
|
|
Загрузка…
Ссылка в новой задаче