mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
Merge d517779e7c
into 7ac34a6aec
This commit is contained in:
commit
a0cd35c32f
@ -15,7 +15,7 @@ onboot:
|
||||
- name: sysfs
|
||||
image: linuxkit/sysfs:23a13bbf83bf666ef6a3ba7b3ebba35d2daead98
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -13,7 +13,7 @@ onboot:
|
||||
image: linuxkit/dhcpcd:f46134c05f9665d8865a9fbebd5be0995057af28
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "/dev/sda"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -13,7 +13,7 @@ onboot:
|
||||
image: linuxkit/dhcpcd:f46134c05f9665d8865a9fbebd5be0995057af28
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "/dev/sda"]
|
||||
- name: dm-crypt
|
||||
image: linuxkit/dm-crypt:ad2a05dcffa28ef809a61aa27ba230c82f02f603
|
||||
|
@ -20,7 +20,7 @@ onboot:
|
||||
image: linuxkit/binfmt:564e110729c8d8ecc365979a7d149e2851942883
|
||||
# Format and mount the disk image in /var/lib/docker
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib"]
|
||||
|
@ -12,7 +12,7 @@ onboot:
|
||||
- name: sysfs
|
||||
image: linuxkit/sysfs:23a13bbf83bf666ef6a3ba7b3ebba35d2daead98
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -13,7 +13,7 @@ onboot:
|
||||
image: linuxkit/dhcpcd:f46134c05f9665d8865a9fbebd5be0995057af28
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/external"]
|
||||
|
@ -20,13 +20,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
labelVar string
|
||||
fsTypeVar string
|
||||
partTypeVar string
|
||||
forceVar bool
|
||||
verboseVar bool
|
||||
drives map[string]bool
|
||||
driveKeys []string
|
||||
labelVar string
|
||||
fsTypeVar string
|
||||
partTypeVar string
|
||||
forceVar bool
|
||||
verboseVar bool
|
||||
drives map[string]bool
|
||||
partitionLayoutVar string
|
||||
driveKeys []string
|
||||
)
|
||||
|
||||
func hasPartitions(d string) bool {
|
||||
@ -73,7 +74,7 @@ func isEmptyDevice(d string) (bool, error) {
|
||||
return isEmpty, nil
|
||||
}
|
||||
|
||||
func autoformat(label, fsType string, partType string) error {
|
||||
func autoformat(label, fsType string, partType string, partitionLayoutVar string) error {
|
||||
var first string
|
||||
for _, d := range driveKeys {
|
||||
if verboseVar {
|
||||
@ -94,7 +95,7 @@ func autoformat(label, fsType string, partType string) error {
|
||||
return fmt.Errorf("No eligible disks found")
|
||||
}
|
||||
|
||||
return format(first, label, fsType, partType, false)
|
||||
return format(first, label, fsType, partType, partitionLayoutVar, false)
|
||||
}
|
||||
|
||||
func refreshDevicesAndWaitFor(awaitedDevice string) error {
|
||||
@ -129,7 +130,7 @@ func refreshDevicesAndWaitFor(awaitedDevice string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func format(d, label, fsType string, partType string, forced bool) error {
|
||||
func format(d, label, fsType string, partType string, partitionLayoutVar string, forced bool) error {
|
||||
if forced {
|
||||
// clear partitions on device if forced format and they exist
|
||||
if hasPartitions(d) {
|
||||
@ -137,7 +138,7 @@ func format(d, label, fsType string, partType string, forced bool) error {
|
||||
log.Printf("Clearing partitions on %s because forced format was requested", d)
|
||||
}
|
||||
partCmd := exec.Command("sfdisk", "--quiet", "--delete", d)
|
||||
partCmd.Stdin = strings.NewReader(";")
|
||||
partCmd.Stdin = strings.NewReader(partitionLayoutVar)
|
||||
if out, err := partCmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("Error deleting partitions with sfdisk: %v\n%s", err, out)
|
||||
}
|
||||
@ -169,7 +170,7 @@ func format(d, label, fsType string, partType string, forced bool) error {
|
||||
|
||||
// format one large partition
|
||||
partCmd := exec.Command("sfdisk", "--quiet", d)
|
||||
partCmd.Stdin = strings.NewReader(";")
|
||||
partCmd.Stdin = strings.NewReader(partitionLayoutVar)
|
||||
if out, err := partCmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("Error running sfdisk: %v\n%s", err, out)
|
||||
}
|
||||
@ -267,6 +268,7 @@ func init() {
|
||||
flag.StringVar(&labelVar, "label", "", "Disk label to apply")
|
||||
flag.StringVar(&fsTypeVar, "type", "ext4", "Type of filesystem to create")
|
||||
flag.StringVar(&partTypeVar, "partition", "dos", "Type of partition table to create")
|
||||
flag.StringVar(&partitionLayoutVar, "layout", ";", "Partition layout for sfdisk invocation")
|
||||
flag.BoolVar(&verboseVar, "verbose", false, "Enable verbose output (default false)")
|
||||
}
|
||||
|
||||
@ -292,7 +294,7 @@ func main() {
|
||||
if flag.NArg() == 0 {
|
||||
// auto-detect drives if a device to format is not explicitly specified
|
||||
findDrives()
|
||||
if err := autoformat(labelVar, fsTypeVar, partTypeVar); err != nil {
|
||||
if err := autoformat(labelVar, fsTypeVar, partTypeVar, partitionLayoutVar); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
} else {
|
||||
@ -303,13 +305,13 @@ func main() {
|
||||
}
|
||||
|
||||
if forceVar == true {
|
||||
if err := format(candidateDevice, labelVar, fsTypeVar, partTypeVar, forceVar); err != nil {
|
||||
if err := format(candidateDevice, labelVar, fsTypeVar, partTypeVar, partitionLayoutVar, forceVar); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
} else {
|
||||
// add the deviceVar to the array of devices to consider autoformatting
|
||||
driveKeys = []string{candidateDevice}
|
||||
if err := autoformat(labelVar, fsTypeVar, partTypeVar); err != nil {
|
||||
if err := autoformat(labelVar, fsTypeVar, partTypeVar, partitionLayoutVar); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ onboot:
|
||||
image: linuxkit/dhcpcd:f46134c05f9665d8865a9fbebd5be0995057af28
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -15,7 +15,7 @@ onboot:
|
||||
image: linuxkit/dhcpcd:f46134c05f9665d8865a9fbebd5be0995057af28
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -12,7 +12,7 @@ onboot:
|
||||
- name: sysfs
|
||||
image: linuxkit/sysfs:23a13bbf83bf666ef6a3ba7b3ebba35d2daead98
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -13,7 +13,7 @@ onboot:
|
||||
- name: sysctl
|
||||
image: linuxkit/sysctl:112fe3d480ccb6cd115d9d6c446f9d833f6b8e68
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib"]
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
command: ["/usr/bin/mountie", "/var/lib/docker"]
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/modprobe:fad39ef443853ef02520052cdbf6acbeb4ec7799
|
||||
command: ["modprobe", "btrfs"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-type", "btrfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-type", "xfs"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-partition", "gpt"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-label", "docker"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "@DEVICE@"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -9,7 +9,7 @@ onboot:
|
||||
image: linuxkit/modprobe:fad39ef443853ef02520052cdbf6acbeb4ec7799
|
||||
command: ["modprobe", "btrfs"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-type", "btrfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-type", "xfs" ]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,19 +6,19 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sda"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sdb"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "xfs", "/dev/sda"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-verbose", "-force", "-type", "xfs", "/dev/sdb"]
|
||||
- name: test
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
command: ["sh", "./check.sh"]
|
||||
|
@ -6,7 +6,7 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-partition", "gpt"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
@ -6,10 +6,10 @@ init:
|
||||
- linuxkit/runc:8b5af3365fc7d015db4e44113d93c7b1f8e2d2ab
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-label", "docker"]
|
||||
- name: format
|
||||
image: linuxkit/format:8f487d728959192289e0783784fc2b185eadbc82
|
||||
image: linuxkit/format:ced02d849206371b6983eff1eb28f9515406fef0
|
||||
command: ["/usr/bin/format", "-label", "foo"]
|
||||
- name: mount
|
||||
image: linuxkit/mount:2a507ef30302693682f9f612289028df00c58ac5
|
||||
|
Loading…
Reference in New Issue
Block a user