add new btrfs ssd routine

This commit is contained in:
Tobias Powalowski 2014-04-09 17:18:21 +02:00
parent 52e66ddb1e
commit a2292b7f54

View file

@ -1950,14 +1950,12 @@ btrfs_compress() {
fi fi
} }
# ask for btrfs ssd option # check for btrfs ssd option
btrfs_ssd() { btrfs_ssd() {
BTRFS_SSD="NONE" BTRFS_SSD="NONE"
if [[ "${BTRFS_SUBVOLUME}" = "NONE" ]]; then for i in $(${_LSBLK} NAME,TYPE ${PART} -s | grep "disk$" | cut -d' ' -f 1); do
DIALOG --defaultno --yesno "Would you like to optimize the data for ssd disk usage on ${PART}?" 0 0 && BTRFS_SSD="ssd" [[ "$(cat /sys/block/$(basename ${i})/queue/rotational)" == "0" ]] && BTRFS_SSD="ssd"
else done
DIALOG --defaultno --yesno "Would you like to optimize the data for ssd disk usage on ${PART} subvolume=${BTRFS_SUBVOLUME}?" 0 0 && BTRFS_SSD="ssd"
fi
} }
# values that are only needed for btrfs creation # values that are only needed for btrfs creation
@ -2405,6 +2403,8 @@ _mkfs() {
[[ "${_btrfssubvolume}" = "NONE" ]] && _btrfssubvolume="" [[ "${_btrfssubvolume}" = "NONE" ]] && _btrfssubvolume=""
# add btrfs raid level, if needed # add btrfs raid level, if needed
[[ ! "${_btrfslevel}" = "NONE" && "${_fstype}" = "btrfs" ]] && _fsoptions="${_fsoptions} -d ${_btrfslevel}" [[ ! "${_btrfslevel}" = "NONE" && "${_fstype}" = "btrfs" ]] && _fsoptions="${_fsoptions} -d ${_btrfslevel}"
# add btrfs options, minimum requirement linux 3.14 -O extref,skinny-metadata,no-holes
[[ "${_fstype}" = "btrfs" ]] && _fsoptions="${_fsoptions} -O extref,skinny-metadata,no-holes"
# we have two main cases: "swap" and everything else. # we have two main cases: "swap" and everything else.
if [[ "${_fstype}" = "swap" ]]; then if [[ "${_fstype}" = "swap" ]]; then
swapoff ${_device} >/dev/null 2>&1 swapoff ${_device} >/dev/null 2>&1