mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Merge pull request #3508 from federico-pellegatta/extend-pkg-gpt-support
Add GUID Partition Table (GPT) support to `extend` and `mount` packages
This commit is contained in:
commit
6d1ffc9118
@ -17,7 +17,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
||||
services:
|
||||
|
@ -16,7 +16,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "/dev/sda"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/dev/sda1", "/var/external"]
|
||||
- name: loop
|
||||
image: linuxkit/losetup:0730b61ac5c8803ba73318c2dd5121dc15cfbf34
|
||||
@ -25,7 +25,7 @@ onboot:
|
||||
image: linuxkit/dm-crypt:0ea63bfd97b719d185b69994b4856d97fbc8a2dd
|
||||
command: ["/usr/bin/crypto", "crypt_loop_dev", "/dev/loop0"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/dev/mapper/crypt_loop_dev", "/var/secure_storage"]
|
||||
- name: bbox
|
||||
image: busybox
|
||||
|
@ -19,7 +19,7 @@ onboot:
|
||||
image: linuxkit/dm-crypt:0ea63bfd97b719d185b69994b4856d97fbc8a2dd
|
||||
command: ["/usr/bin/crypto", "crypt_dev", "/dev/sda1"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/dev/mapper/crypt_dev", "/var/secure_storage"]
|
||||
- name: bbox
|
||||
image: busybox
|
||||
|
@ -22,7 +22,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib"]
|
||||
# make a swap file on the mounted disk
|
||||
- name: swap
|
||||
|
@ -14,7 +14,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
services:
|
||||
- name: getty
|
||||
|
@ -15,7 +15,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/external"]
|
||||
- name: swap
|
||||
image: linuxkit/swap:2cf5c3f08c4b238bb5fe231fd59ce19faee0fbc6
|
||||
|
@ -82,7 +82,10 @@ func extend(d, fsType string) error {
|
||||
}
|
||||
|
||||
partition := f.PartitionTable.Partitions[0]
|
||||
if partition.Type != "83" {
|
||||
// fail on anything that isn't a Linux partition
|
||||
// 83 -> MBR/DOS Linux Partition ID
|
||||
// 0FC63DAF-8483-4772-8E79-3D69D8477DE4 -> GPT Linux Partition GUID
|
||||
if partition.Type != "83" && partition.Type != "0FC63DAF-8483-4772-8E79-3D69D8477DE4" {
|
||||
return fmt.Errorf("Partition 1 on disk %s is not a Linux Partition", d)
|
||||
}
|
||||
|
||||
@ -176,7 +179,7 @@ func createPartition(d string, partition Partition) error {
|
||||
}
|
||||
|
||||
createCmd := exec.Command("sfdisk", "-q", d)
|
||||
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,83;", partition.Start))
|
||||
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,%s;", partition.Start, partition.Type))
|
||||
if err := createCmd.Run(); err != nil {
|
||||
return fmt.Errorf("Error creating partition table: %v", err)
|
||||
}
|
||||
|
@ -98,7 +98,9 @@ func findFirst(drives []string) (string, error) {
|
||||
|
||||
for _, partition := range f.PartitionTable.Partitions {
|
||||
// ignore anything that isn't a Linux partition
|
||||
if partition.Type != "83" {
|
||||
// 83 -> MBR/DOS Linux Partition ID
|
||||
// 0FC63DAF-8483-4772-8E79-3D69D8477DE4 -> GPT Linux Partition GUID
|
||||
if partition.Type != "83" && partition.Type != "0FC63DAF-8483-4772-8E79-3D69D8477DE4" {
|
||||
continue
|
||||
}
|
||||
if _, ok := mounted[partition.Node]; ok {
|
||||
|
@ -17,7 +17,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
services:
|
||||
- name: getty
|
||||
|
@ -17,7 +17,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
services:
|
||||
- name: getty
|
||||
|
@ -14,7 +14,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
services:
|
||||
- name: rngd
|
||||
|
@ -15,7 +15,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib"]
|
||||
- name: test
|
||||
image: linuxkit/test-containerd:fa781a2ec490a63140a2e90f9c8d13c735dd4c5f
|
||||
|
@ -9,5 +9,5 @@ function failed {
|
||||
|
||||
[ -f /var/lib/docker/bar ] || failed
|
||||
touch /var/lib/docker/foo || failed
|
||||
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
printf "extend test suite PASSED\n" >&1
|
||||
|
@ -8,7 +8,7 @@ onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -6,9 +6,9 @@ init:
|
||||
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
|
||||
onboot:
|
||||
- name: extend
|
||||
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
|
||||
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,5 +9,5 @@ function failed {
|
||||
|
||||
[ -f /var/lib/docker/bar ] || failed
|
||||
touch /var/lib/docker/foo || failed
|
||||
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
printf "extend test suite PASSED\n" >&1
|
||||
|
@ -12,7 +12,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-type", "btrfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,10 +9,10 @@ onboot:
|
||||
image: linuxkit/modprobe:944769462b9d10b1b1506498d3eb03dcc5416f7f
|
||||
command: ["modprobe", "btrfs"]
|
||||
- name: extend
|
||||
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
|
||||
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
|
||||
command: ["/usr/bin/extend", "-type", "btrfs"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,5 +9,5 @@ function failed {
|
||||
|
||||
[ -f /var/lib/docker/bar ] || failed
|
||||
touch /var/lib/docker/foo || failed
|
||||
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
printf "extend test suite PASSED\n" >&1
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-type", "xfs"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -6,10 +6,10 @@ init:
|
||||
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
|
||||
onboot:
|
||||
- name: extend
|
||||
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
|
||||
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
|
||||
command: ["/usr/bin/extend", "-type", "xfs"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
13
test/cases/040_packages/005_extend/003_gpt/check.sh
Executable file
13
test/cases/040_packages/005_extend/003_gpt/check.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "extend test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -f /var/lib/docker/bar ] || failed
|
||||
touch /var/lib/docker/foo || failed
|
||||
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
|
||||
printf "extend test suite PASSED\n" >&1
|
25
test/cases/040_packages/005_extend/003_gpt/test-create.yml
Normal file
25
test/cases/040_packages/005_extend/003_gpt/test-create.yml
Normal file
@ -0,0 +1,25 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:5.4.30
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:f670045ecb6ec31ea37dd10114366e9a1e915013
|
||||
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-partition", "gpt"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
binds:
|
||||
- /var/lib/docker:/var/lib/docker
|
||||
command: ["touch", "/var/lib/docker/bar"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:06dd4e46c62fbe79123a028835c921f80e4855d3
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
- library
|
32
test/cases/040_packages/005_extend/003_gpt/test.sh
Normal file
32
test/cases/040_packages/005_extend/003_gpt/test.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that a partition on a GPT partitioned disk can be extended
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME_CREATE=create-gpt
|
||||
NAME_EXTEND=extend-gpt
|
||||
DISK=disk.img
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME_CREATE}-* ${NAME_EXTEND}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
linuxkit build -name "${NAME_CREATE}" -format kernel+initrd test-create.yml
|
||||
linuxkit run -disk file="${DISK}",format=raw,size=256M "${NAME_CREATE}"
|
||||
[ -f "${DISK}" ] || exit 1
|
||||
# osx takes issue with bs=1M
|
||||
dd if=/dev/zero bs=1048576 count=256 >> "${DISK}"
|
||||
linuxkit build -format kernel+initrd -name ${NAME_EXTEND} test.yml
|
||||
RESULT="$(linuxkit run -disk file=${DISK} ${NAME_EXTEND})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
28
test/cases/040_packages/005_extend/003_gpt/test.yml
Normal file
28
test/cases/040_packages/005_extend/003_gpt/test.yml
Normal file
@ -0,0 +1,28 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:5.4.30
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:f670045ecb6ec31ea37dd10114366e9a1e915013
|
||||
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
|
||||
onboot:
|
||||
- name: extend
|
||||
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
|
||||
- name: mount
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
binds:
|
||||
- /var/lib/docker:/var/lib/docker
|
||||
- /check.sh:/check.sh
|
||||
command: ["sh", "./check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:06dd4e46c62fbe79123a028835c921f80e4855d3
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
- library
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-label", "docker"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "-label", "docker", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "@DEVICE@"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "-device", "@DEVICE@1", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -12,7 +12,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-type", "btrfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-type", "xfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-partition", "gpt"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
@ -12,10 +12,10 @@ onboot:
|
||||
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
|
||||
command: ["/usr/bin/format", "-label", "foo"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "-label", "docker", "/var/lib/docker"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
|
||||
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
|
||||
command: ["/usr/bin/mountie", "-label", "foo", "/var/foo"]
|
||||
- name: test
|
||||
image: alpine:3.11
|
||||
|
Loading…
Reference in New Issue
Block a user