2 # create linux-swap partitions
4 # Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
20 require_512_byte_sector_size_
22 ######################################################################
23 # When creating a partition of type linux-swap(v1) in a DOS partition
24 # table, ensure that the proper file system type (0x82) is used.
25 # Some releases, e.g. parted-1.8.8 would mistakenly use 0x83.
26 ######################################################################
30 # create a file to simulate the underlying device
31 dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null || fail=1
34 parted -s $dev mklabel msdos > out 2>&1 || fail=1
35 compare out /dev/null || fail=1
38 parted -s $dev mkpart primary 2048s 4095s > out 2>&1 || fail=1
39 compare out /dev/null || fail=1
41 # create a linux-swap file system
42 parted -s $dev mkfs 1 "linux-swap(v1)" > out 2>&1 || fail=1
43 compare out /dev/null || fail=1
45 # Extract the byte at offset 451. It must be 0x82, not 0x83.
46 # extract byte 451 (fs-type)
47 od -t x1 -An -j450 -N1 $dev > out && echo " 82" > exp || fail=1
49 # expect it to be 82, not 83
50 compare out exp || fail=1
52 # create another file to simulate the underlying device
53 dd if=/dev/null of=$dev2 bs=1 seek=$N 2> /dev/null || fail=1
55 # label another test disk
56 parted -s $dev2 mklabel msdos > out 2>&1 || fail=1
57 compare out /dev/null || fail=1
59 # create another partition
60 parted -s $dev2 mkpart primary 2048s 4095s > out 2>&1 || fail=1
61 compare out /dev/null || fail=1
63 # create another linux-swap file system
64 parted -s $dev2 mkfs 1 "linux-swap(v1)" > out 2>&1 || fail=1
65 compare out /dev/null || fail=1
67 # partition starts at offset 1048576; swap UUID is 1036 bytes in
69 od -t x1 -An -j1049612 -N16 $dev > uuid1 || fail=1
71 od -t x1 -An -j1049612 -N16 $dev2 > uuid2 || fail=1
72 # two linux-swap file systems must have different UUIDs
73 cmp uuid1 uuid2 && fail=1
75 # check linux-swap file system
76 parted -s $dev2 check 1 > out 2>&1 || fail=1
77 compare out /dev/null || fail=1
80 od -t x1 -An -j1049612 -N16 $dev2 > uuid2-new || fail=1
81 # check preserves linux-swap UUID
82 compare uuid2 uuid2-new || fail=1
84 # create a linux-swap file system via alias
85 parted -s $dev mkfs 1 linux-swap > out 2>&1 || fail=1
86 compare out /dev/null || fail=1