Merge pull request #93 from carlroth/roth_bigdisk

Updates for larger disks with non-default block sizes
This commit is contained in:
Jeffrey Townsend
2016-07-22 14:53:02 -07:00
committed by GitHub
3 changed files with 101 additions and 15 deletions

View File

@@ -399,10 +399,26 @@ installer_mkchroot "${rootdir}"
mkdir -p "${rootdir}/mnt/installer"
mount -o ro,bind "${installer_dir}" "${rootdir}/mnt/installer"
# make the onie boot files available to the chroot
mkdir -p "${rootdir}/mnt/onie-boot"
if test -d "/mnt/onie-boot"; then
mount -o ro,bind "/mnt/onie-boot" "${rootdir}/mnt/onie-boot"
# make sure onie-boot is mounted
if test -d /mnt/onie-boot; then
if grep -q " /mnt/onie-boot " /proc/mounts; then
:
else
ONIE_BOOT_DEVICE=
visit_blkid blkid_find_onie
if test -b "$ONIE_BOOT_DEVICE"; then
installer_say "Mounting ONIE-BOOT ($ONIE_BOOT_DEVICE) as /mnt/onie-boot"
mount -o defaults,rw $ONIE_BOOT_DEVICE /mnt/onie-boot
else
installer_say "*** missing ONIE-BOOT device"
fi
fi
if grep -q " /mnt/onie-boot " /proc/mounts; then
# make the onie boot files available to the chroot
mkdir -p "${rootdir}/mnt/onie-boot"
mount -o ro,bind "/mnt/onie-boot" "${rootdir}/mnt/onie-boot"
fi
fi
# generate config for installer environment

View File

@@ -123,6 +123,53 @@ installer_mkchroot() {
fi
}
visit_blkid()
{
local fn rest
fn=$1; shift
rest="$@"
local ifs
ifs=IFS; IFS=$CR
for line in $(blkid); do
IFS=$ifs
local dev
dev=${line%%:*}
line=${line#*:}
local TYPE LABEL PARTLABEL UUID PARTUUID
while test "$line"; do
local key
key=${line%%=*}
line=${line#*=}
case "$line" in
'"'*)
line=${line#\"}
val=${line%%\"*}
line=${line#*\"}
line=${line## }
;;
*)
val=${line%% *}
line=${line#* }
;;
esac
eval "$key=\"$val\""
done
local sts
eval $fn \"$dev\" \"$LABEL\" \"$UUID\" \"$PARTLABEL\" \"$PARTUUID\" $rest
sts=$?
if test $sts -eq 2; then break; fi
if test $sts -ne 0; then return $sts; fi
done
IFS=$ifs
return 0
}
# Local variables
# mode: sh
# sh-basic-offset: 2

View File

@@ -225,9 +225,28 @@ class Base:
devices = {}
def _u2s(sz, u):
"""Convert to units of logical sectors."""
bsz = sz * u
bsz = bsz + self.partedDevice.physicalSectorSize - 1
return bsz / self.partedDevice.physicalSectorSize
bsz = bsz + self.partedDevice.sectorSize - 1
return bsz / self.partedDevice.sectorSize
def _align(spos):
"""Align this sector number."""
sz = self.partedDevice.sectorSize
psz = self.partedDevice.physicalSectorSize
if type(psz) != int: return spos
if psz <= sz: return spos
if (psz % sz) != 0: return spos
if psz > 1048576: return spos
stride = psz / sz
off = spos % stride
off = stride - off
off = off % stride
spos += off
return spos
UNITS = {
'GiB' : 1024 * 1024 * 1024,
@@ -260,7 +279,7 @@ class Base:
part, sz)
return 1
start = nextBlock
start = _align(nextBlock)
end = start + cnt - 1
if end <= self.partedDevice.getLength():
self.log.info("Allocating %d sectors for %s",
@@ -526,15 +545,17 @@ class GrubInstaller(SubprocessMixin, Base):
self.log.info("disk is %s", self.partedDevice.path)
self.log.info("found %s partitions (bsz %s, lbsz %s)",
self.partedDisk.type,
self.partedDevice.sectorSize,
self.partedDevice.physicalSectorSize)
if self.partedDisk.type != 'gpt':
self.log.error("not a GPT partition table")
return 1
if self.partedDevice.sectorSize != 512:
self.log.error("invalid logical block size")
return 1
self.log.warn("invalid logical block size, expected 512")
if self.partedDevice.physicalSectorSize != 512:
self.log.error("invalid physical block size")
return 1
self.log.warn("invalid physical block size, expected 512")
self.log.info("found a disk with %d blocks",
self.partedDevice.getLength())
@@ -745,15 +766,17 @@ class UbootInstaller(SubprocessMixin, Base):
self.log.info("Installing to %s", self.device)
self.log.info("found %s partitions (bsz %s, lbsz %s)",
self.partedDisk.type,
self.partedDevice.sectorSize,
self.partedDevice.physicalSectorSize)
if self.partedDisk.type != 'msdos':
self.log.error("not an MSDOS partition table")
return 1
if self.partedDevice.sectorSize != 512:
self.log.error("invalid logical block size")
return 1
self.log.warn("invalid logical block size, expected 512")
if self.partedDevice.physicalSectorSize != 512:
self.log.error("invalid physical block size")
return 1
self.log.warn("invalid physical block size, expected 512")
self.log.info("found a disk with %d blocks",
self.partedDevice.getLength())