Amazon Web Services and CentOS Helpful Information

 

S3 Bucket Commands
Command to unmount #fusermount -u /s3
Command to mount #/usr/bin/s3fs -o allow_other bucketname /s3
Other Commands
#sudo echo "yourawskey:yourawssecret" > /etc/passwd-s3fs
#sudo chmod 640 /etc/passwd-s3fs
#sudo /usr/bin/s3fs yours3bucket /yourmountpoint -ouse_cache=/tmp
Verify with mount
Information Link https://code.google.com/p/s3fs/wiki/FuseOverAmazon

 

CentOS Add Swap
1 Check if swap exists.
#swapon -s
2 Check the file system. #df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda 20642428 1347968 18245884 7% /
3 Create and enable the file system. #sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
“of=/swapfile” designates the file’s name. In this case the name is swapfile.
4 Create linux swap area. #sudo mkswap /swapfile
Setting up swapspace version 1, size = 536866 kB
5 Activate swap file. #sudo swapon /swapfile
6 Verify swap is on. #swapon -s
Filename Type Size Used Priority
/swapfile file 524280 0 -1
This file will last on the server until the machine reboots. You can ensure that the swap is permanent by adding it to the fstab file.
7 Edit file /etc/fstab.
8 Past in this line. 
/swapfile swap swap defaults 0 0
9 Set permissions. #chown root:root /swapfile
10 Set permissions. #chmod 0600 /swapfile
Adjust swappiness if desired (0-100).
#cat /proc/sys/vm/swappiness
#sysctl vm.swappiness=10
#vm.swappiness=10
#cat /proc/sys/vm/swappiness
edit /etc/sysctl.conf add:
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
vm.swappiness=10

 

CentOS Resize EBS Volume
1 Look at the file system, it is 6G. # df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      6.0G  2.0G  3.7G  35% /
tmpfs            15G     0   15G   0% /dev/shm
2 Look at the disk and the partition, the disk is 21.5 GB but the partition is 6 GB (6291456 blocks). # fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders
Units = cylinders of 1649 * 512 = 844288 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           2        7632     6291456   83  Linux
3 Start fdisk for that disk (xvda, so not the partition xvda1). # fdisk /dev/xvda
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
4 Switch to sector display. Command (m for help): u
Changing display/entry units to sectors
5 Print the partition(s), and remember the start sector (2048 in the example). Command (m for help): p
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    12584959     6291456   83  Linux
6 Delete the partition. Command (m for help): d
Selected partition 1
7 Create a new partition. Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
8 Make it primary. p
9 First partition. Partition number (1-4): 1
10 Enter the old start sector, do NOT make any typo here!!! (2048 in the example). First sector (17-41943039, default 17): 2048
11 Hit enter to accept the default (this is the remainder of the disk). Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
12 Print the changes and make sure the start sector is ok, if not restart at #6. Command (m for help): p
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot      Start         End      Blocks   Id  System
/dev/xvda1            2048    41943039    20970496   83  Linux
13 Make the partition bootable. do NOT forget this!!! Command (m for help): a
14 Enter your partition number (1 in the example). Partition number (1-4): 1
15 Write the partition info back, this will end the fdisk session. Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
16 Reboot the server, and wait for it to come up (this may take longer than usual). # reboot
17 Verify the filesystem size. # df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G  2.0G   17G  11% /
tmpfs            15G     0   15G   0% /dev/shm
18 If the filesystem is not around 20Gb as expected, you can use this command. # resize2fs /dev/xvda1
resize2fs 1.41.12 (date)
The filesystem is already 5242624 blocks long.  Nothing to do!

 

Share