Created
July 31, 2015 16:02
-
-
Save adragomir/b97e6af3ff5623ffb2eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Create AWS partitions | |
DefaultDependencies=false | |
Before=local-fs-pre.target var.mount mnt-data_1.mount -.mount local-fs.target | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/sh /etc/early-boot.sh | |
RemainAfterExit=yes | |
[Install] | |
RequiredBy=local-fs-pre.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -b /dev/xvdb1 ]; then | |
echo "Creating partition on /dev/xvdb1" | |
parted -s -a optimal /dev/xvdb mklabel gpt -- mkpart primary xfs 1 -1 | |
partprobe /dev/xvdb | |
mkfs.xfs /dev/xvdb1 | |
else | |
echo "Partition already created on /mnt/data_1" | |
fi | |
echo "Mounting partition" | |
mount /dev/xvdb1 /mnt/data_1 | |
# Create directories on instance store | |
if [ ! -d /mnt/data_1/var ]; then | |
echo "Copying /var" | |
mkdir -p -m 777 /mnt/data_1/var | |
#cp -a /var/* /mnt/data_1/var/ | |
rsync -a /var/* /mnt/data_1/var/ | |
# cd /var | |
#find . -depth -print0 | sudo cpio --null --sparse -pvd /mnt/data_1/var | |
#mv /var /var.old | |
#mkdir -p /var | |
else | |
echo "/var is already copied" | |
fi | |
umount /mnt/data_1 | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
none /dev/pts devpts gid=5,mode=620 0 0 | |
none /proc proc defaults 0 0 | |
none /sys sysfs defaults 0 0 | |
/dev/xvdb1 /mnt/data_1 xfs rw,relatime,attr2,inode64,noquota 0 0 | |
/mnt/data_1/var /var none bind,x-systemd.requires=mnt-data_1.mount 0 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am trying to create a partition on an unmounted drive and move the /var folder to it. | |
The idea I have is: | |
1. Create the partition and copy /var data to it - execute this before any fs is mounted | |
2. Normal boot continues, picks up the stuff from /etc/fstab and mounts the partitions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment