This is achieved by wic adding entries to the fstab during image
generation. In order for a valid fstab to be generated one of the
--ondrive, --ondisk or --use-uuid partition options must be used for
- each partition that specifies a mountpoint.
+ each partition that specifies a mountpoint. Note that with --use-uuid
+ and non-root <mountpoint>, including swap, the mount program must
+ understand the PARTUUID syntax. This currently excludes the busybox
+ versions of these applications.
The following are supported 'part' options:
in bootloader configuration before running wic. In this case .wks file can
be generated or modified to set preconfigured parition UUID using this option.
+ --fsuuid: This option is specific to wic. It specifies filesystem UUID.
+ It's useful if preconfigured filesystem UUID is added to kernel command line
+ in bootloader configuration before running wic. In this case .wks file can
+ be generated or modified to set preconfigured filesystem UUID using this option.
+
--system-id: This option is specific to wic. It specifies partition system id. It's useful
for the harware that requires non-default partition system ids. The parameter
in one byte long hex number either with 0x prefix or without it.
import logging
import os
+import uuid
from wic import WicError
from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var
self.system_id = args.system_id
self.use_uuid = args.use_uuid
self.uuid = args.uuid
+ self.fsuuid = args.fsuuid
self.lineno = lineno
self.source_file = ""
if self.label:
label_str = "-L %s" % self.label
- mkfs_cmd = "mkfs.%s %s %s %s -d %s" % \
- (self.fstype, extraopts, rootfs, label_str, rootfs_dir)
+ mkfs_cmd = "mkfs.%s %s %s %s -U %s -d %s" % \
+ (self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
if self.label:
label_str = "-L %s" % self.label
- mkfs_cmd = "mkfs.%s -b %d -r %s %s %s %s" % \
+ mkfs_cmd = "mkfs.%s -b %d -r %s %s %s -U %s %s" % \
(self.fstype, rootfs_size * 1024, rootfs_dir, label_str,
- self.mkfs_extraopts, rootfs)
+ self.mkfs_extraopts, self.fsuuid, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir,
extraopts = self.mkfs_extraopts or '-S 512'
- dosfs_cmd = "mkdosfs %s %s %s -C %s %d" % \
- (label_str, size_str, extraopts, rootfs, rootfs_size)
+ dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
+ (label_str, self.fsuuid, size_str, extraopts, rootfs,
+ rootfs_size)
exec_native_cmd(dosfs_cmd, native_sysroot)
mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
if self.label:
label_str = "-L %s" % self.label
- mkfs_cmd = "mkfs.%s -F %s %s %s" % \
- (self.fstype, extraopts, label_str, rootfs)
+ mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \
+ (self.fstype, extraopts, label_str, self.fsuuid, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot)
def prepare_empty_partition_btrfs(self, rootfs, oe_builddir,
if self.label:
label_str = "-L %s" % self.label
- mkfs_cmd = "mkfs.%s -b %d %s %s %s" % \
- (self.fstype, self.size * 1024, label_str,
+ mkfs_cmd = "mkfs.%s -b %d %s -U %s %s %s" % \
+ (self.fstype, self.size * 1024, label_str, self.fsuuid,
self.mkfs_extraopts, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot)
extraopts = self.mkfs_extraopts or '-S 512'
- dosfs_cmd = "mkdosfs %s %s %s -C %s %d" % \
- (label_str, extraopts, size_str, rootfs, blocks)
+ dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
+ (label_str, self.fsuuid, extraopts, size_str, rootfs,
+ blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
with open(path, 'w') as sparse:
os.ftruncate(sparse.fileno(), self.size * 1024)
- import uuid
label_str = ""
if self.label:
label_str = "-L %s" % self.label
- mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
+
+ mkswap_cmd = "mkswap %s -U %s %s" % (label_str, self.fsuuid, path)
exec_native_cmd(mkswap_cmd, native_sysroot)
continue
if part.use_uuid:
- device_name = "PARTUUID=%s" % part.uuid
+ if part.fsuuid:
+ # FAT UUID is different from others
+ if len(part.fsuuid) == 10:
+ device_name = "UUID=%s-%s" % \
+ (part.fsuuid[2:6], part.fsuuid[6:])
+ else:
+ device_name = "UUID=%s" % part.fsuuid
+ else:
+ device_name = "PARTUUID=%s" % part.uuid
else:
# mmc device partitions are named mmcblk0p1, mmcblk0p2..
prefix = 'p' if part.disk.startswith('mmcblk') else ''
continue
part.realnum = realnum
- # generate parition UUIDs
+ # generate parition and filesystem UUIDs
for part in self.partitions:
if not part.uuid and part.use_uuid:
if self.ptable_format == 'gpt':
part.uuid = str(uuid.uuid4())
else: # msdos partition table
part.uuid = '%08x-%02d' % (self.identifier, part.realnum)
+ if not part.fsuuid:
+ if part.fstype == 'vfat' or part.fstype == 'msdos':
+ part.fsuuid = '0x' + str(uuid.uuid4())[:8].upper()
+ else:
+ part.fsuuid = str(uuid.uuid4())
def prepare(self, imager):
"""Prepare an image. Call prepare method of all image partitions."""