How to create a swapfile on a btrfs filesystem

Some things you should be aware of:

  1. Linux Kernel 5.x supports swapfiles natively on btrfs
  2. This is a bit of a kludge.

Summary:

Btrfs does not natively support swapfiles as the kernel wants them to be contiguous blocks on disk.To work around this, we create a loop-mounted filesystem that is formatted ext4, and in that filesystem, we create a swapfile.

Background:

Btrfs as a filesystem is much more similar to a modify on write filesystem like Netapp’s wafl or ZFS. It’s a copy-on-write filesystem, so it’s not quite the same, but under the hood, a files blocks aren’t necessarily stored next to each other. Historically, the kernel wanted the blocks in a swapfile to be next to each other and contiguous, because on spinning disk, seek time is what kills you.

Workflow:

Create a 2.5G  swapfile:

dd if=/dev/zero of=/var/loopdisk.img bs=1024 count=2500000

Format the file with ext4:

 mkfs.ext4 /var/loopdisk.img

Mount the file and make it permanent:

mkdir /mnt/loop-ext4fs
mount -t ext4 -o loop /var/loopdisk.img /mnt/loop-ext4fs/ && \
  grep '/mnt/loop-ext4fs' /etc/mtab >> /etc/fstab

Create the swapfile:

dd if=/dev/zero of=/mnt/loop-ext4fs/swapfile bs=1024 count=2000000
chmod 600 /mnt/loop-ext4fs/swapfile
mkswap /mnt/loop-ext4fs/swapfile
swapon /mnt/loop-ext4fs/swapfile

Verify that it worked:

 free -h --si
              total        used        free      shared  buff/cache   available
Mem:           4.0G        153M        123M        966K        3.8G        3.6G
Swap:          2.0G          0B        2.0G

Add an entry to the /etc/fstab for the swapfile:

/mnt/loop-ext4fs/swapfile       none    swap    sw       0      0

Verify that it will be used as swap when the sytem boots:

swapoff -a
free -h --si
              total        used        free      shared  buff/cache   available
Mem:           4.0G        152M        122M        966K        3.8G        3.6G
Swap:            0B          0B          0B
swapon -a
free -h --si
              total        used        free      shared  buff/cache   available
Mem:           4.0G        153M        121M        966K        3.8G        3.6G
Swap:          2.0G          0B        2.0G

It’s not a terrible idea to reboot to make sure that everything will work on startup.

Posted in linux, tech | Leave a comment

Netapp Network testing with iperf3

Here’s an interesting NetApp thing I was playing around with. There’s a command in diag mode: “network test-link”, which is ostensibly to test throughput between nodes. In the man page, it mentions that it is based on iperf3 — Just to see if it would work, installed iperf3 on a linux box, and was able to do a run-test against the linux system’s ip address, and also do a “network test-link start-server” and run a load test from the linux box against the system’s ip address. This is useful because you can use it to isolate network testing from causing i/o on the system and potentially impacting things in the same volume like you would with sio or iometer.

Centos doesn’t have iperf3 by default, but you can add the extra packages for enterprise linux (https://fedoraproject.org/wiki/EPEL) and then just do a yum install iperf3 and you’re good to go.

Posted in netapp, tech, Uncategorized | Leave a comment

Quick Little Powershell Script

Here’s a quick little powershell script I wrote to illustrate the relationship between Aggregates, Shelves, and raid-groups for a student who was a little confused as to their relationship:

$raidGroup = 0;
$shelf=1;
$rgSize=8;
$shelfBays = 24
$numShelves = 2
$totalDisks = ($numShelves * $shelfBays)

write-output("Aggregate Start");
for ( $i = 0 ; $i -lt $totalDisks ; $i++) { 

    $shelfMody = $i % $shelfBays ; 
    $mody = $i % $rgSize ;
    if ( 0 -eq $shelfMody ) {
        Write-Output("------------SHELF------------");
        }
    if ( 0 -eq $mody ) {
        Write-Output("RaidGroup: $raidGroup");
        $raidGroup++;
        $Parity = 2 ; 
    }
    if ( $Parity -eq 2 ) {
        Write-Output("    Parity Disk #1: $i");
        $Parity--;
        } elseif ( $Parity -eq 1 ) {
        Write-Output("    Parity Disk #2: $i");
        $Parity--;
        } else {
        Write-Output("    data Disk: $i");
        }
    }

You can see some of the output below:

Aggregate Start
------------SHELF------------
RaidGroup: 0
    Parity Disk #1: 0
    Parity Disk #2: 1
    data Disk: 2
    data Disk: 3
    data Disk: 4
    data Disk: 5
    data Disk: 6
    data Disk: 7
RaidGroup: 1
    Parity Disk #1: 8
    Parity Disk #2: 9
    data Disk: 10
    data Disk: 11
    data Disk: 12
    data Disk: 13
    data Disk: 14
    data Disk: 15
RaidGroup: 2
    Parity Disk #1: 16
    Parity Disk #2: 17
    data Disk: 18
    data Disk: 19
    data Disk: 20
    data Disk: 21
    data Disk: 22
    data Disk: 23
------------SHELF------------
RaidGroup: 3
    Parity Disk #1: 24
    Parity Disk #2: 25
    data Disk: 26
    data Disk: 27
    data Disk: 28
    data Disk: 29
    data Disk: 30
    data Disk: 31
RaidGroup: 4
    Parity Disk #1: 32
    Parity Disk #2: 33
    data Disk: 34
    data Disk: 35
    data Disk: 36
    data Disk: 37
    data Disk: 38
    data Disk: 39
RaidGroup: 5
    Parity Disk #1: 40
    Parity Disk #2: 41
    data Disk: 42
    data Disk: 43
    data Disk: 44
    data Disk: 45
    data Disk: 46
    data Disk: 47
Posted in netapp, programming, tech | Tagged , , | Leave a comment

Giving away my minolta maxxum 400si

I’m giving away my old minolta 400si to a photography student after years of it sitting in the closet collecting dust. It took me a full two or three months to save up for this thing in ’01, back when I was broke as hell. I’m glad someone’s going to be using it, but I’ve got a feeling it’s going to sting a little bit when they come to actually pick it up.

Posted in Life | Tagged , , | Leave a comment

Ripping my dvd collection

So a while back we had a smallish earth quake, which made my shelves, which were none-to-sturdy anyway, decide the walls were no longer where they wanted to be. I came home to dvds strewn across the floor, and more-or-less, that’s where they’ve stayed ever since (in a slightly neater form, anyway).

About a month or so ago, I decided I would digitize my movie collection, and throw them on one of my home servers. Yes, I have multiple. Yes, there is something wrong with me. Anyway, after finding xbmc works fantastically out of the box on ubuntu, and uses upnp to advertize media to my xbox, it was a no-brainer. The only problem is it takes sooooooooo long to rip a dvd. I’m getting to the point where I might just bittorrent them because it’s faster than ripping the ones I already own. I wonder what the legality of that is.

Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment

Hacked. :/

My hosted web-server got hacked last night. I’m guessing it was via dokuwiki, which was out of date, but dang it, that’s annoying. Never-the-less, tip of the hat to Hidden Pain. Egg on my face.

For the next couple days, I’m going to be replacing the current site, made up of custom-written code, some of which dates back to 1997, with a wordpress blog which will be a bit easier to maintain. Apologies for any broken links or inconvenience.

-Nick

Posted in Uncategorized | Tagged , , , , | Leave a comment

More airline strangeness

Me: hi, I was wondering if any upgrades are available, and if so, how much they cost.

Gate agent: oh, next time just have them put you on the list when you check your bag.

Me: oh, I’m a united frequent flyer, not air Canada. I don’t think I can.

Gate agent: oh, sorry, then we can’t put you on the upgrade list.

Me: I actually don’t want to use miles, or standby. I’d like to see how much it would cost.

Gate agent: I’m sorry sir, we can’t do that with united miles.

Me: I want to pay cash. Do you take cash?

Gate agent: no. We don’t take cash.

Wft? I just tried to give a company money and they refused to take it. Is there a more fundamental principal of business? If a customer wants to buy something, and you can provide it, sell it to them.

Posted in Uncategorized | Leave a comment

Netapp Instructor Wanted

Hi all,

I just wanted to let you know that there is an open position for a Netapp Instructor. You should have extensive real-world netapp experience, be personable, funny, able to tell stories and explain complex subjects in a simple manner. People who have worked as PSEs are probably a good fit. The salary is very competitive, but the main benefits are in the flexibility and schedule. You’ll get to travel (I’ve been to places like hong kong on the company dime) and meet lots of people. I generally only work about two weeks / month, but some some instructors work every week. We will happily teach you how to teach, but just to be up-front, the process of becoming an instructor isn’t instant. You’ll have to take each of the course three times (one to audit, one to co-teach, and one supervised-solo), and you’ll have to do this for the fundamentals class, the san, nfs, cifs, data protection and boot camp classes – it can take a while. Once you’re through that however, I can personally attest to the fact that it’s an *amazing* job.

You would be reporting to me, and I’m a pretty darn good boss. 🙂 Well, I am if you like my management style, anyway. Basically all I want is regular reports on how things are going, what help (if any) you need to do your job better, and then I leave you the heck alone. One of the main benefits of this job is you are your own boss, effectively sub-contracting, and we just make sure you’ve got everything you need, make sure your reviews are consistently good, and you’re getting exposed to the new stuff coming down the pipe. There will also be great opportunities to get exposed to all sorts of other technologies too – cisco, vmware, ubuntu linux – it’s really fun to be able to audit a whole range of different courses, and then bring that back to your netapp classes.

If you’re interested, please email me your resume, or a link to it – any standard format is fine. For bonus points, pretend you’re talking to an eight year old, and explain why the sky is blue. Feel free to look it up, but the actual answer should be yours.

Kindest Regards,
Nick Bernstein, Director of Netapp training, ICM
[si-contact-form form=’1′]
Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment

How changing my homepage let me loose forty pounds and start a company.

Almost two years ago, I decided I was going to sit down and make some changes to my life. I had just finished a four year stint at microsoft, felt burnt out on tech, gotten out of shape due to working regular sixty hour weeks in front of a computer and smoking like a chimney. I sat down and thought about what it was that I wanted to achieve and came up with a list of stuff that I wanted to do. I decided to focus on accomplishing three -smoking, weight loss, and starting a company. I did several things to accomplish these goals, but one of the best, and easiest, was just changing my home page.
Nowadays, when I open up my browser in the morning, I’m greated with three pages. They are as follows: (my company) entrenza.com’s beta page, gmail, and foremost – a google docs spreadsheet entitled yyyy-mm goals and actions. The beta page is related to one of these goals, but lets talk about the spreadsheet. It’s really simple and looks something like this:


Monday Tuesday Wednesday Thursday Friday Saturday Sunday
Goal 1 action another action
Goal 2 action another action
Goal 3 action action

It’s been a pretty successful system. I don’t worry about huge strides, I just worry about accomplishing, one thing towards each goal each day. So far, ‘ve registered a LLC and and have regularly worked part time on a startup for over a year. We’re right about to go into beta. As for getting in shape, when I left seattle two years ago and got my California license, it listed my weight at 205lbs. I renewed last week and had 185lbs on it. Prior to leaving Seattle, you could add another 20 lbs to that. I no longer smoke.

I don’t know if this will be useful to anyone else, but I’ve had some success with it, and who knows, maybe it will work for you. If you try it out, I’d love to hear from you and see how it goes.

Posted in entrenza, Life, tech | Tagged , , , , | Leave a comment

More Human than Human

I’ve been working on a startup project on the side for almost a year now – focusing on pattern recognition, natural language processing stuff, and predictive statistical modeling… it’s been fun. At the core, we’ve put together a language analysis engine which looks at a chunk of text and figures out if it’s positive or negative. In researching this as a problem, we’ve determined that if you take three individuals, and then have them categorize the same random text (blog, article, website, tweet, etc) they will agree 63% of the time. There’s a little bit of variance depending on what’s shown, but plus or minus a couple percentage points, is about how accurate a human is. We’ve gone through several different models in doing the predictions, and tweaked the algorithm quite a bit over multiple different versions, but we recently hit a pretty major milestone – we’re now rating articles, or our engine is, with a 70+% accuracy rate. In other words, if we rate something as positive (meaning the author felt positive about whatever they were writing) 70% of the time, the human will agree with how we rated it. ^_^

We’re better at determining human opinion than the average human is.

We’re going to be going into beta soon, on a service that will allow you to track how positive or negative your brand is, by tracking the mentions on the internet – effectively doing sentiment analysis and tracking; if you’re interested, you can sign up here. You can read more about the project in general at www.entrenza.com.

Thanks to Steve & Jesse & Ben, my co-collaborators on the project for making this happen!

Posted in entrenza, startup, tech | Tagged , , , , | Leave a comment